INSERT INTO语句语法错误 求解
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim logname As String
Dim logpsw As String
logname = TextBox1.Text
logpsw = TextBox2.Text
Dim connect As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection
connect.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("App_Data/database/book.mdb"))
Try
connect.Open()
Response.Write("SUCCEED")
Catch ex As Exception
Response.Write(ex)
End Try
Try
Dim cmd As System.Data.OleDb.OleDbCommand = New System.Data.OleDb.OleDbCommand
Dim result As Integer
cmd.Connection = connect
=
= "insert into BOOK (username,password) values ('" + logname + " ',' " + logpsw + " ')"
result = cmd.ExecuteNonQuery()
Response.Write("write successfully")
Catch ex As Exception
Response.Write(ex.Message)
End Try
connect.Close()
End Sub
点了这个button以后,打开数据库成功,显示SUCCEED,但紧接着就报错说INSERT INTO 语句的语法错误,补充一下,相应的ACCESS数据库里的BOOK表里所有属性都可以是空值。。。。。希望大虾们赐教
再补充一下response.write()后的运行结果是
insert into BOOK (username,password) values ('ASS ',' ASS ')
应该没问题
[ 本帖最后由 kiska3088915 于 2010-11-4 14:48 编辑 ]