大家帮看一下这个代码错在哪里!
Imports System.Data
Imports System.Data.OleDb
Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cnn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("database.mdb"))
cnn.Open()
Dim cmm As New OleDbCommand("insert into fsx(username,password) values('fsx','123')", cnn)
cmm.ExecuteNonQuery()
lab.Text = "tttttttttttttttttttttttttttttttttttttt"
cnn.Close()
End Sub
End Class
出错信息是:
“/WebApplication2”应用程序中的服务器错误。
INSERT INTO 语句的语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.OleDb.OleDbException: INSERT INTO 语句的语法错误。
源错误:
行 29: cnn.Open()
行 30: Dim cmm As New OleDbCommand("insert into fsx(username,password) values('fsx','123')", cnn)
行 31: cmm.ExecuteNonQuery()
行 32: lab.Text = "tttttttttttttttttttttttttttttttttttttt"
行 33: cnn.Close()
源文件: D:\Mymakes\aspnet\agent\WebApplication2\WebForm1.aspx.vb 行: 31
堆栈跟踪:
[OleDbException (0x80040e14): INSERT INTO 语句的语法错误。]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +174
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +92
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +65
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +112
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +67
WebApplication2.WebForm1.Page_Load(Object sender, EventArgs e) in D:\Mymakes\aspnet\agent\WebApplication2\WebForm1.aspx.vb:31
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731