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 に答える