Reputation: 11
I have tried everything, but without success. connection variable is assigned to my database Url.
Here is my code:
Private Sub GunaButton1_Click(sender As Object, e As EventArgs) Handles GunaButton1.Click
'MySQL query string
Dim command As New MySqlCommand("INSERT INTO `Register`(`Username`, `Password`) VALUES (@usr,@pw,)", Connection)
' Command parameters
command.Parameters.Add("@usr", MySqlDbType.VarChar).Value = BunifuMaterialTextbox3.Text
command.Parameters.Add("@pw", MySqlDbType.VarChar).Value = BunifuMaterialTextbox4.Text
Connection.Open()
If command.ExecuteNonQuery() = 1 Then
MessageBox.Show("Data Inserted")
Else
MessageBox.Show("ERROR")
End If
End Sub
The error it's giving me:
MySql.Data.MySqlClient.MySqlException: 'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1'
Upvotes: 0
Views: 262
Reputation: 54477
The error message is telling you that you have an error in your SQL syntax and it appears that you have not bothered to check your SQL syntax. You have a spurious comma in your value list. VALUES (@usr,@pw,)
should be VALUES (@usr,@pw)
.
Upvotes: 2