Dim Conn As New OleDb.OleDbConnection
Dim connstr As String
Dim ad As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\vb.mdb"
Dim dt As New DataSet
Dim sql As String
sql = "insert into admin(usename,password) values ('" + Me.TextBox1.Text + "' , '" + Me.TextBox1.Text + "')"
Conn = New OleDb.OleDbConnection(connstr)
Conn.Open()
Dim cmd As New OleDb.OleDbCommand(sql, Conn)
cmd.ExecuteNonQuery()
Conn.Close()
MsgBox("ok!")
这段代码是向数据库插入记录的,如果SQL语句为sql = "insert into admin(usename) values ('" & Me.TextBox1.Text & "' )" (只插入一个列),就能成功,也能插入数据,但是如果想插入两个列,就在
cmd.ExecuteNonQuery() 出说insert into 语法错误,到底是怎么回事,昨天晚上弄到4:00也没搞定,今天起早继续,依然没弄好,