0
我看不到有什麼不對我的SQL語句的語法代碼是在這裏:ODBC VB投擲語法錯誤
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
只是爲了清楚起見,實際插入語句是這樣一些數據:
"INSERT INTO Accounts (Username,Password,Str,Int,Agi,Money) VALUES ('MyUsername','MyPassword',0,0,0,0)"
給出的錯誤是:
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
非常感謝。
感謝bugtussle的快速反應,工作完美。 – iiNsyD 2010-09-07 19:18:39
或者如果你不能嘗試用Int替換Int。 – 2012-08-06 14:43:47