views:

7

answers:

1

I cant see what is wrong with my SQL statement syntax code is here:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Using Con1 As New Odbc.OdbcConnection("Driver={MySQL ODBC 5.1 Driver};Server=127.0.0.1;Database=MyGame;User=root; Password=MyPasswordWhichIWontTellYou;")
        Dim mInsertSQL As String
        mInsertSQL = "INSERT INTO Accounts (Username,Password,Str,Int,Agi,Money) VALUES ('" & txtUser.Text & "','" & txtPass.Text & "'," & Int(txtStr.Text) & "," & Int(txtInt.Text) & "," & Int(txtAgi.Text) & ",0);"
        Dim Cmd1 As New Odbc.OdbcCommand(mInsertSQL, Con1)
        Try
            Con1.Open()
            Cmd1.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Using
End Sub

Just for clarity the actual insert statement is this with some data:

"INSERT INTO Accounts (Username,Password,Str,Int,Agi,Money) VALUES ('MyUsername','MyPassword',0,0,0,0)"

The error given is:

ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.1.41]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 'Int,Agi,Money) VALUES ('MyUsername','MyPassword',0,0,0,0)' at line 1

Thanks alot.

A: 

Wild Guess: 'Int' as a field name may be reserved, maybe you could try another name for the field?

bugtussle
Thanks bugtussle for the quick response, worked perfectly.
iiNsyD