且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

VB.net 到 MySql 存储过程错误

更新时间:2023-02-13 17:29:32

您可以尝试改为直接调用(我还没有测试过:

You might try changing to a direct call (I haven't tested this:

 cmd.CommandType = CommandType.Text
 cmd.CommandText = "CALL GetRuntestToday"

此外,还有一种更好的代码编写方式:

Also, a better way of writing your code:

Dim MyConString As String = "My String Details"
Using dbcRuntest As New OdbcConnection(MyConString)
  dbcRuntest.Open()
  Using cmd As New OdbcCommand("CALL GetRuntestToday", dbcRuntest)
    cmd.CommandType = CommandType.Text
    Using reader As OdbcDataReader = cmd.ExecuteReader
      'do someting with reader'
    End Using
  End Using 
End Using

Using 结构自动关闭连接并处理它(连同其他对象).

The Using structure automatically closes the connection and disposes it (along with the other objects).

编辑为使用 CALL 而不是 EXECUTE