0
我得到這個錯誤,而我測試下面的代碼:誤差在MySQL語法在vb.net
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 '[student](ID, LASTNAME, FIRSTNAME, SCHOOL) VALUES ('333', 'aaa', 'aaa', 'aaa')' at line 1
我只是循環,我操縱MS SQL數據庫所使用的代碼。所以語法一定是錯的。將記錄添加到mysql數據庫中的正確語法是什麼? 這裏是我當前的代碼:
idnum = TextBox1.Text
lname = TextBox2.Text
fname = TextBox3.Text
skul = TextBox4.Text
Using sqlcon As New MySqlConnection("Server=localhost; Database=testing;Uid=root;Pwd=nitoryolai123$%^;")
sqlcon.Open()
Dim sqlcom As New MySqlCommand()
sqlcom.Connection = sqlcon
sqlcom.CommandText = "INSERT INTO [student](ID, LASTNAME, FIRSTNAME, SCHOOL) VALUES (@ParameterID, @ParameterLastName, @ParameterFirstName, @ParameterSchool)"
sqlcom.Parameters.AddWithValue("@ParameterID", TextBox1.Text)
sqlcom.Parameters.AddWithValue("@ParameterLastName", TextBox2.Text)
sqlcom.Parameters.AddWithValue("@ParameterFirstName", TextBox3.Text)
sqlcom.Parameters.AddWithValue("@ParameterSchool", TextBox4.Text)
sqlcom.ExecuteNonQuery()
End Using
請幫幫忙,謝謝