private void Page_Load(object sender, System.EventArgs e)
{
base.HeaderIconImageUrl=Request.ApplicationPath+"/Images/securekey.gif";
base.HeaderMessage="Registration Form";
if(Page.IsPostBack)
{
return;
}
if(Context.User.Identity.IsAuthenticated)
{
OleDbDataReader OleDbDReader;
base.HeaderMessage="Update my profile";
string strConn="Provider=Microsoft.Jet.OleDb.4.0;";
strConn+=@"Data Source=C:\Documents and Settings\Administrator\VSWebCache\BT-CONTROL\FriendsReunion\Data\User.mdb";
OleDbConnection myConn=new OleDbConnection(strConn);
string sqlSelect="select * from consumer where Login='"+
Page.User.Identity.Name+"'";
OleDbCommand OleDbComm=new OleDbCommand(sqlSelect,myConn);
myConn.Open();
OleDbDReader=OleDbComm.ExecuteReader(CommandBehavior.CloseConnection);
if(OleDbDReader.Read())
{
int pos=OleDbDReader.GetOrdinal("Address");
this.txtAddr.Text=OleDbDReader.GetString(pos).ToString();
this.txtBirth.Text=OleDbDReader.GetDateTime(OleDbDReader.GetOrdinal("DateOfBirth")).ToShortDateString();
this.txtEmail.Text=OleDbDReader["Email"].ToString();
this.txtFName.Text=OleDbDReader["First Name"].ToString();
this.txtLName.Text=OleDbDReader["Last Name"].ToString();
this.txtLogin.Text=OleDbDReader["User Name"].ToString();
this.txtPhone.Text=OleDbDReader["Phone Number"].ToString();
this.txtPWD.Text=OleDbDReader["Password"].ToString();
pos=OleDbDReader.GetOrdinal("Mobile Number");
SqlString cel;
cel=OleDbDReader.GetString(pos);
if(!cel.IsNull)
{
this.txtMobile.Text=cel.Value;
}
}
OleDbDReader.Close();
myConn.Close();
}
}
求助!编译运行是提示已成功,为什么在ie浏览器里却显示
“/Friends”应用程序中的服务器错误。
--------------------------------------------------------------------------------
First Name
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.IndexOutOfRangeException: First Name
源错误:
行 74: this.txtBirth.Text=OleDbDReader.GetDateTime(OleDbDReader.GetOrdinal("DateOfBirth")).ToShortDateString();
行 75: this.txtEmail.Text=OleDbDReader["Email"].ToString();
行 76: this.txtFName.Text=OleDbDReader["First Name"].ToString();
行 77: this.txtLName.Text=OleDbDReader["Last Name"].ToString();
行 78: this.txtLogin.Text=OleDbDReader["User Name"].ToString();
源文件: c:\documents and settings\administrator\vswebcache\bt-control\friendsreunion\secure\newuser.aspx.cs 行: 76
堆栈跟踪:
[IndexOutOfRangeException: First Name]
System.Data.Common.FieldNameLookup.GetOrdinal(String fieldName) +55
System.Data.OleDb.OleDbDataReader.GetOrdinal(String name) +63
System.Data.OleDb.OleDbDataReader.get_Item(String name) +10
FriendsReunion.secure.NewUser.Page_Load(Object sender, EventArgs e) in c:\documents and settings\administrator\vswebcache\bt-control\friendsreunion\secure\newuser.aspx.cs:76
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
请高手帮忙看看!!谢了!
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.2032; ASP.NET 版本:1.1.4322.2032