我正在开发一个基于Windows的VB.NET应用程序,它可以作为后端和Web服务器使用mysql。我使用Web服务(asmx)连接到数据库,所有操作都运行良好。有时对于某些SELECT查询,它不会产生任何结果(也没有错误),对于同一查询,它会在一小时后或第二天生成结果。由于这种行为,我找不到任何错误的标签并继续该项目。
如果你能让我知道发生了什么,请提前致谢
代码在
之下<SoapHeader("Authentication")> _
<WebMethod(Description:="Get the result from sql query - Returns a Dataset")> _
Public Function ExecuteQuery(ByVal strQuery As String) As DataSet
Dim ds As DataSet = New DataSet 'create a DataSet to hold the results
If decryptString(Authentication.Username) = "bla bla" AndAlso decryptString(Authentication.Password) = "bla blah" Then
Try
'create a MySqlCommand to represent the query
If sqlConn.State = ConnectionState.Closed Then
sqlConn = New MySqlConnection(conStr)
sqlConn.Open()
End If
Dim sqlcmd As MySqlCommand = sqlConn.CreateCommand()
sqlcmd.CommandType = CommandType.Text
sqlcmd.CommandText = strQuery
'create a MySqlDataAdapter object
Dim sqlDa As MySqlDataAdapter = New MySqlDataAdapter
sqlDa.SelectCommand = sqlcmd
Try
'fill the DataSet using the DataAdapter
sqlDa.Fill(ds, "Results")
Catch ex As Exception
Throw New ApplicationException("Error-luckie's server 1 " & ex.Message)
End Try
Catch ex As Exception
Throw New ApplicationException("Error-luckie's server 2 " & ex.Message)
Finally
sqlConn.Close()
sqlConn.Dispose()
End Try
End If
Return ds
End Function