string id = yonghuming.Text.ToString();
string pwd = mima.Text.ToString();
OleDbConnection connection = new OleDbConnection();
connection.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath(@"~\App_Data\ping.mdb");
string oledb = "select * from login where yonghu='" + id + "'and password1='" + pwd + "'";
OleDbCommand command = new OleDbCommand(oledb, connection);
connection.Open();
OleDbDataReader rs = command.ExecuteReader();
if(rs.Read())
{
Session["uid"] = rs["id"].ToString();
Response.Write("<script language='javascript'>alert('恭喜您注册成功');</script>");
Label3.Text = yonghuming.Text + ",";
yonghuming.Text = "";
mima.Text = "";
}
else
{
Response.Write("<script language='javascript'>alert('对不起您没有注册成功');</script>");
mima.Text = "";
}
connection.Close();
为什么在调试时,出现异常IndexOutOfRangeException
列表中的最大索引小于列表的大小!
string pwd = mima.Text.ToString();
OleDbConnection connection = new OleDbConnection();
connection.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath(@"~\App_Data\ping.mdb");
string oledb = "select * from login where yonghu='" + id + "'and password1='" + pwd + "'";
OleDbCommand command = new OleDbCommand(oledb, connection);
connection.Open();
OleDbDataReader rs = command.ExecuteReader();
if(rs.Read())
{
Session["uid"] = rs["id"].ToString();
Response.Write("<script language='javascript'>alert('恭喜您注册成功');</script>");
Label3.Text = yonghuming.Text + ",";
yonghuming.Text = "";
mima.Text = "";
}
else
{
Response.Write("<script language='javascript'>alert('对不起您没有注册成功');</script>");
mima.Text = "";
}
connection.Close();
为什么在调试时,出现异常IndexOutOfRangeException
列表中的最大索引小于列表的大小!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货