输入那句话还是可以正常,就是运行时报错
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Write(use_txt.Text)
Response.Write("<br>")
Response.Write(pwd_txt.Text)
Response.Write("<br>")
Dim dd As New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("App_Data\md.mdb"))
Dim sql As String = "insert into user(user,pwd) values ( '" + use_txt.Text + "' ,'" + pwd_txt.Text + " ')"
Response.Write(sql)
Response.Write("<br>")
dd.Open()
Dim sd As New Data.OleDb.OleDbCommand(sql, dd)
Try
sd.ExecuteNonQuery()
Catch ex As Exception
Response.Write(ex.ToString)
End Try
Response.Write("<script language='jvavscript'>alert('操作成功');</script>")
End Sub
End Class
运行结果:
asdsa
sadsa
insert into user(user,pwd) values ( 'asdsa' ,'sadsa ')
System.Data.OleDb.OleDbException: INSERT INTO 语句的语法错误。 在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) 在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) 在 System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) 在 System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) 在 System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) 在 System.Data.OleDb.OleDbCommand.ExecuteNonQuery() 在 _Default.Button1_Click(Object sender, EventArgs e) 位置 F:\\Default.aspx.vb:行号 19