Link to home
Start Free TrialLog in
Avatar of jimseiwert
jimseiwertFlag for United States of America

asked on

VB.NET MySql Store Procedure

It is my first time having to call a mysql store procedure from vb.net. I am trying to use the below code but it keeps saying

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SP_Validate_user' at line 1

What am i doing wrong? The store procedure does not show any problems. It commited successful
Imports MySql.Data
Imports MySql.Data.MySqlClient
 
    Public Shared Function validate_user_credentials(ByVal username As String, ByVal password As String) As Boolean
        Dim myConnection As New MySqlConnection
        myConnection = New MySqlConnection(myConnectionString)
        Dim myCommand As New MySqlCommand("SP_Validate_user")
        myCommand.Connection = myConnection
        myConnection.Open()
 
        myCommand.Parameters.AddWithValue("Username", username)
        myCommand.Parameters.AddWithValue("UPassword", password)
 
        Dim sqlReader As MySql.Data.MySqlClient.MySqlDataReader = myCommand.ExecuteReader
        While sqlReader.Read()
            MsgBox(sqlReader(0))
            MsgBox(sqlReader(1))
        End While
        myCommand.Connection.Close()
 
        sqlReader = Nothing
    End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of rionroc
rionroc
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you want to learn more, please visit:
http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-1


Great is our GOD.
:)
Avatar of klay8
klay8

try this
Dim myConnection As New MySqlConnection
        myConnection = New MySqlConnection(myConnectionString)

    Dim myCommand As New MySqlCommand(" Call SP_Validate_user('&username&"','"&password"')"
myCommand.CommandType = CommandType.StoredProcedure;      
  myCommand.Connection = myConnection
        myConnection.Open()