各位高人,在下初学C#asp.net,在进行access操作时碰到一个问题,请教各位: 5
各位高人,在下初学C#asp.net,在进行access操作时碰到一个问题,请教各位:protectedvoidButton1_Click(objectsender,Ev...
各位高人,在下初学C#asp.net,在进行access操作时碰到一个问题,请教各位:
protected void Button1_Click(object sender, EventArgs e)
{
string username;
string password;
username= this.Userbox.Text;
password=this.Passbox.Text;
string connstr = "provider=microsoft.jet.oledb.4.0;data source=" +
Server.MapPath("/app_data\\Acc_MData.mdb") + ";Persist Security Info=False";
OleDbConnection conn = new OleDbConnection(connstr);
conn.Open();
string sqlstr = "select count(opername) from acc_operation where opername='"
+ username + "' and operpassord ='" + password + "'";
OleDbCommand cmd = new OleDbCommand (sqlstr, conn );
OleDbDataReader rd = cmd.ExecuteReader();
//执行到上面这一行的时候出错:“System.Data.OleDb.OleDbException”类型的异常在 System.Data.dll 中发生,但未在用户代码中进行处理
//请问各位该如何修改?
if (rd.Read ())
{
Response.Redirect("AccMainfrm.aspx");
}
else
{
Response.Write("用户名或者密码错误!");
}
}
已经搞定,感谢各位! 展开
protected void Button1_Click(object sender, EventArgs e)
{
string username;
string password;
username= this.Userbox.Text;
password=this.Passbox.Text;
string connstr = "provider=microsoft.jet.oledb.4.0;data source=" +
Server.MapPath("/app_data\\Acc_MData.mdb") + ";Persist Security Info=False";
OleDbConnection conn = new OleDbConnection(connstr);
conn.Open();
string sqlstr = "select count(opername) from acc_operation where opername='"
+ username + "' and operpassord ='" + password + "'";
OleDbCommand cmd = new OleDbCommand (sqlstr, conn );
OleDbDataReader rd = cmd.ExecuteReader();
//执行到上面这一行的时候出错:“System.Data.OleDb.OleDbException”类型的异常在 System.Data.dll 中发生,但未在用户代码中进行处理
//请问各位该如何修改?
if (rd.Read ())
{
Response.Redirect("AccMainfrm.aspx");
}
else
{
Response.Write("用户名或者密码错误!");
}
}
已经搞定,感谢各位! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询