Hi Guys and Galls
I’m trying to update a table in mysql database using the following code
[SIZE=“1”]Public Sub InsertUsers(ByVal sender As Object, ByVal e As EventArgs)
Dim sqlInsert As String
sqlInsert = "INSERT INTO tblTestComp(strUserName, strPassword, DOB) "
sqlInsert += “VALUES(?, ?, ?)”
Dim objCmd As MySqlCommand
objCmd = New MySqlCommand(sqlInsert, objConnMySQL)
Dim i As Integer = 0
objConnMySQL.Open()
For i = 0 To 2
objCmd.Parameters.Add(New MySqlParameter())
Next
objCmd.Parameters(0).Value = “BillWordsWorth”
objCmd.Parameters(1).Value = “Kipper88”
objCmd.Parameters(2).Value = “1985-05-21”
objCmd.ExecuteNonQuery()
objConnMySQL.Close()
End Sub[/SIZE]
The error I get is Object reference not set to an instance of an object
on the line objCmd.Parameters.Add(New MySqlParameter())
When I change the connection, command and parameters to oledb objects and run against MS Access databse it works fine. I have been trying to amend it for 2 days now to work with MySQL objects but nothing seems to work
I would be very grateful for any ideas
Thanks