程序代码如下:
<%@ Page Language="vb" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
Dim conn As new OleDbConnection
Dim cm As new OleDbCommand
sub page_load(sender as Object,e as EventArgs)
'1.连接数据库
dim dbname as string
dbname=server.mappath("\data\user.mdb")
conn.connectionstring= "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" & dbname
conn.Open()
l1.text="Connection Opened!"
'2.添加记录
dim sql as string
'sql= "Insert INTO user(nama,pwd) Values('Simson','usa')"
sql="select * from user"
cm.connection=conn
cm.commandtext=sql
cm.ExecuteNonQuery
l2.text=sql
end sub
</script>
<html>
<head>
</head>
<body>
<asp:label id="l1" runat="server"></asp:label>
<br>
<asp:label id="l2" runat="server"></asp:label>
<br>
</body>
</html>
数据库user.mdb为access数据库,字段nama,pwd均为文本型,程序运行时提示如下错误:
FROM 子句语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.OleDb.OleDbException: FROM 子句语法错误。
源错误:
行 23: cm.connection=conn
行 24: cm.commandtext=sql
行 25: cm.ExecuteNonQuery
行 26: l2.text=sql
行 27: end sub
源文件: F:\teacher\exer\tiaoshi.aspx 行: 25
堆栈跟踪:
[OleDbException (0x80040e14): FROM 子句语法错误。]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +122
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
ASP.tiaoshi_aspx.page_load(Object sender, EventArgs e) in F:\teacher\exer\tiaoshi.aspx:25
System.Web.UI.Control.OnLoad(EventArgs e) +55
System.Web.UI.Control.LoadRecursive() +27
System.Web.UI.Page.ProcessRequestMain() +731
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573
请问各位高人,错误码究竟在什么地方?急呀。。。