标题:求助!!!
只看楼主
fsx
Rank: 1
来 自:广西南宁
等 级:新手上路
帖 子:278
专家分:0
注 册:2005-11-9
结帖率:100%
 问题点数:0 回复次数:2 
求助!!!

大家帮看一下这个代码错在哪里!

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

搜索更多相关主题的帖子: 休闲 咨询 password values 
2005-11-11 10:51
梦幻情缘
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:769
专家分:20
注 册:2005-4-4
得分:0 
会不会没有添加参数呀?
2005-11-11 15:42
fsx
Rank: 1
来 自:广西南宁
等 级:新手上路
帖 子:278
专家分:0
注 册:2005-11-9
得分:0 
谢谢搞定了.

做你喜欢做的事
2005-11-26 01:02



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-33406-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.164827 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved