这是我写的把数据库中的数据填充到指定的文本框中的代码.但不能通过编译.
<script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
dim cnn as oledbconnection
dim cmd as oledbcommand
dim dr as oledbdatareader
dim strcnn as string
dim strsql as string
dim use_name as string
dim usename as string
dim useeducate as string
dim usemail as string
dim usesex as integer
dim usejob as string
dim useage as integer
use_name=session("usename")
strcnn="provider=microsoft.jet.oledb.4.0;data source="+server.MapPath("data/db1.mdb")
strsql="select usename,useeducate,usemail,useage,usesex,usejob from useinforma where usename=use_name"
cnn=new oledbconnection(strcnn)
cnn.open()
cmd=new oledbcommand(strsql,cnn)
dr=cmd.executeReader()
if dr.read() then
usename=dr.GetString(1).tostring
useeducate=dr.getstring(2).tostring
usemail=dr.getstring(3).tostring
useage= dr.getint32(4)
usesex= dr.getint32(5)
usejob= dr.getstring(6).tostring
else response.Write("对不起,你没有权限查看个人资料.")
end if
dr.close()
cnn.close()
End Sub
</script>
提示错误是:
至少一个参数没有被指定值。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.OleDb.OleDbException: 至少一个参数没有被指定值。
源错误:
行 25: cmd=new oledbcommand(strsql,cnn)
行 26:
行 27: dr=cmd.executeReader()
行 28: if dr.read() then
行 29: usename=dr.GetString(1).tostring
源文件: D:\Program Files\asp\main.aspx 行: 27
堆栈跟踪:
[OleDbException (0x80040e10): 至少一个参数没有被指定值。]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +267
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +192
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +48
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +106
System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +111
System.Data.OleDb.OleDbCommand.ExecuteReader() +6
ASP.main_aspx.Page_Load(Object Sender, EventArgs E) in D:\Program Files\asp\main.aspx:27
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061