0

我一遍又一遍地遇到错误,有人可以告诉我我的 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 ""
4

1 回答 1

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)
于 2013-03-12T08:02:01.630 回答