我一遍又一遍地收到错误,有人可以告诉我INSERT语句有什么问题吗?
这是我的代码:
Dim SQLcon As New OleDbConnection
Dim SQLdr As OleDbDataReader
Try
SQLcon.ConnectionString = "Provider=Microsoft.ACE.OleDb.12.0;" & _
"Data Source= C:\Users\cleanfuel\Desktop\ProgramniOrig\DBhospital.accdb"
Dim SQLcmd As New OleDbCommand("INSERT INTO tblLogin (Username,Password,SecretQuestion,SecretAnswer)" & _
"VALUES(@Username,@Password,@SecretQuestion,@SecretAnswer)", SQLcon)
SQLcmd.Parameters.AddWithValue("@Username", txtUser.Text)
SQLcmd.Parameters.AddWithValue("@Password", txtPass.Text)
SQLcmd.Parameters.AddWithValue("@SecretQuestion", txtSecretQ.Text)
SQLcmd.Parameters.AddWithValue("@SecretAnswer", txtSecretA.Text)
SQLcon.Open()
MsgBox("Patient Added!", MsgBoxStyle.Information)
SQLdr = SQLcmd.ExecuteReader()
Catch ex As Exception
MessageBox.Show("Error Occured, Can't Register!" & ex.Message)
Finally
SQLcon.Close()
End Try
Return ""
答案 0 :(得分:0)
尝试使用PASSWORD
[]
Dim _query As String = "INSERT INTO tblLogin (Username, " & _
"[Password], SecretQuestion, SecretAnswer) " & _
"VALUES(@Username, @Password, " & _
"@SecretQuestion,@SecretAnswer)"
Dim SQLcmd As New OleDbCommand(_query, SQLcon)