为什么错误???? INSERT INTO语句中的语法错误

时间:2014-12-30 09:29:47

标签: vb.net

Public Sub register_user()
    Dim con As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\User\Documents\login.mdb")
    con.Open()
    Dim reg As New DataTable("loginadmin")
    Dim aaa As New OleDb.OleDbDataAdapter("Select * from loginadmin ", con)
    Dim rs As New OleDb.OleDbCommand("Insert into loginadmin(username,password) values ('" & TextBox1.Text & "', '" & TextBox2.Text & "')", con)



    rs.ExecuteNonQuery()
    MessageBox.Show("user successfully registerd")

    con.Close()

End Sub

'调试器发现此错误“语法错误插入语句” 'da

1 个答案:

答案 0 :(得分:0)

试试这个: - Dim rs As New OleDb.OleDbCommand ("Insert into loginadmin([username],[password]) values ('" & TextBox1.Text & "', '" & TextBox2.Text & "')", con)