0
我在VB.NET中編碼,當我試圖插入記錄時遇到此錯誤我的SQL數據庫。你的SQL語法有錯誤;檢查與您的MySQL服務器版本相對應的手冊,在第1行'')附近使用正確的語法
Public Sub SaveNames(ByRef SQLStatement As String)
Dim cmd As MySqlCommand = New MySqlCommand
With cmd
.CommandText = SQLStatement
.CommandType = CommandType.Text
.Connection = SQLConnection
.ExecuteNonQuery()
End With
SQLConnection.Close()
MsgBox("Successfully Added")
SQLConnection.Dispose()
End Sub
Private Sub cmdSave_Click(sender As Object, e As EventArgs) Handles cmdSave.Click
Dim SQLStatement As String = "INSERT INTO people(name) VALUES (‘" & TextBox1.Text & "')"
SaveNames(SQLStatement)
End Sub
這是一種智能報價?你使用MSWord進行編碼嗎? – Strawberry 2014-09-27 17:10:30
** [如何創建參數化SQL查詢?我爲什麼要?](http://stackoverflow.com/questions/542510/how-do-i-create-a-parameterized-sql-query-why-should-i)** – 2014-09-27 17:13:38