代码一主要想实现添加新用户和密码,,运行的时候老是提示insert into语法错误???、/?,大家帮忙看一下错在哪里?代码二,确能运行
代码一
Try
Dim insertCmd, connStr As String
connStr = "provider=microsoft.jet.oledb.4.0;data source=D:\资料\study\VB.NET\学习\人事信息系统\person.mdb"
insertCmd = "insert into users(user_name,password) values('" & Trim(txtUserName.Text) & "','" & Trim(txtPassword.Text) & "')"
Dim conn As OleDbConnection
Dim cmd As OleDbCommand
conn = New OleDbConnection(connStr)
conn.Open()
cmd = New OleDbCommand(insertCmd, conn)
cmd.ExecuteNonQuery()
conn.Close()
Catch
MsgBox(Err.Description)
代码二
Try
Dim insertCmd, connStr As String
connStr = "provider=microsoft.jet.oledb.4.0;data source=D:\资料\study\VB.NET\学习\人事信息系统\person.mdb"
insertCmd = "insert into users(user_name) values('" & Trim(txtUserName.Text) & "')"
Dim conn As OleDbConnection
Dim cmd As OleDbCommand
conn = New OleDbConnection(connStr)
conn.Open()
cmd = New OleDbCommand(insertCmd, conn)
cmd.ExecuteNonQuery()
conn.Close()
Catch
MsgBox(Err.Description)