我有這樣一段代碼與試&陷阱:獲取VB的一個錯誤:缺少分號(;)在SQL語句的結束
Try
comando = New OleDbCommand("INSERT INTO login VALUES (Usuario, Password, Cuenta)" & Chr(13) &
"VALUES(UsuarioText, PasswordText, TipoText)", conexion)
comando.Parameters.AddWithValue("@Usuario", UsuarioText.Text)
comando.Parameters.AddWithValue("@Password", PasswordText.Text)
comando.Parameters.AddWithValue("@Cuenta", TipoText.Text)
comando.ExecuteNonQuery()
MsgBox("El registro ha sido guardado exitosamente", MsgBoxStyle.Information, "Informacion")
Catch ex As Exception
MsgBox("El registro no se pudo guardar", MsgBoxStyle.Critical, "Informacion")
MsgBox(ex.Message)
End Try
我將嘗試把一些;
在修正錯誤報表的結尾,但仍然無法正常工作。
它可能是什麼?
胡亂猜測,我從來沒有在VB中工作:'COMANDO =新的OleDbCommand(「INSERT INTO登錄值(Usuario,密碼,Cuenta)「&Chr(13)& 」VALUES(UsuarioText,PasswordText,TipoText);「,conexion)'你可以試試這個改變嗎? – Steephen
將「VALUES(UsuarioText,PasswordText,TipoText)」更改爲「VALUES(@UsuarioText,@PasswordText,@TipoText)」,並使參數名稱與字符串中的內容匹配。 – Jeremy
我同意@Steephen。另外,在發佈SQL相關問題時,最好包含您所定位的數據庫平臺。舉例來說,SQL Server並不傾向於關注這個';'字符,但是Oracle對此非常關注。不知道其他平臺,因爲這些是我最常用的兩個。 &Chr(13)&。這是什麼? – PSGuy