寄存器的INSERT INTO语句中的语法错误

时间:2016-09-17 09:32:43

标签: sql

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")

1 个答案:

答案 0 :(得分:0)

请尝试将字段密码括在括号中。

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

使用MS Access时,这应该可以解决问题。