简体   繁体   中英

Syntax error in INSERT INTO statement for register

Dim con As New OleDb.OleDbConnection
        Dim str As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=..\VisitorPass.accdb"
        con = New OleDbConnection(str)
        Dim sql As String = "insert into Visitor(Name,Password)values ('" & txtName.Text & "','" & txtPassword.Text & "')"

        Dim cmd As OleDbCommand
        con.Open()
        cmd = New OleDbCommand(sql, con)
        cmd.ExecuteNonQuery()
        MsgBox("Account is Registered")

Try enclosing the field password in brackets.

insert into Visitor(Name,[Password])values ..

This should do the trick when using MS Access.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM