Method for VB.NET to call the MySQL stored procedure and get the return value
- 2021-06-29 10:45:44
- OfStack
This article describes an example of how VB.NET calls an MySQL stored procedure and gets a return value.Share it for your reference.The implementation is as follows:
Dim myConnectionString As String = "Database=" & myDatabase & _
" ;Data Source=" & myHost & _
";User Id=" & myUserId & ";Password=" & myPassword
Dim myConnection As New MySqlConnection(myConnectionString)
Try
myConnection.Open()
Catch MyException As MySqlException
Console.WriteLine("Connection error: MySQL code: " & MyException.Number & _
" " + MyException.Message)
End Try
Try
Dim myCommand As New MySqlCommand("call error_test_proc(1)")
myCommand.Connection = myConnection
myCommand.ExecuteNonQuery()
Catch MyException As MySqlException
Console.WriteLine("Stored procedure error: MySQL code: " & _
MyException.Number & " " & _
MyException.Message)
End Try
I hope that the description in this paper will be helpful to everyone's VB.NET program design.