我正在处理一个应用程序,我编写了下面的代码,
Public Function CreateDatatable(ByVal SqlQuery As String, ByVal strTable As String, Optional ByVal OrderbyField As String = "") As DataTable
If InitDB() Then
Try
Dim sqlAdapter As New MySqlDataAdapter()
Dim dt As New DataTable()
If SqlQuery = "" Then SqlQuery = "Select * from " & strTable & IIf(OrderbyField <> "", " order by " & OrderbyField, "")
Dim cmd As New MySqlCommand(SqlQuery, MySQLCon)
cmd.CommandTimeout = 18000
sqlAdapter.SelectCommand = cmd
dt.TableName = strTable
sqlAdapter.Fill(dt)
CreateDatatable = dt
Catch ex As Exception
ServiceLog.WriteEntry("CreateDatatable Exception:" & ex.Message)
End Try
Else
CreateDatatable = Nothing
End If
End Function
运行代码后发生此错误。
MySql.Data.MySqlClient.MySqlException = {“期间遇到致命错误 命令执行。“} at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) at MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior) 在System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior行为) 在System.Data.Common.DbDataAdapter.FillInternal(DataSet数据集,DataTable [] datatables,Int32 startRecord,Int32 maxRecords,String srcTable,IDbCommand命令,CommandBehavior行为) 在System.Data.Common.DbDataAdapter.Fill(DataTable [] dataTables,Int32 startRecord,Int32 maxRecords,IDbCommand命令,CommandBehavior行为) 在System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) at AgilityNewsService.clsDataware_MySQL.CreateDatatable(String SqlQuery,String strTable,String OrderbyField)在C:\ ISMSCleanDesktop \ DesktopBkup_Tue10-22-2013 \ AgilityNewsService \ AgilityNewsService \ AgilityNewsService \ clsDataware_MySQL.vb:第48行
如何解决上述错误?