用户登录简单后台代码
int userflag;
string strconn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\BlogSystem.mdb;Persist Security Info=True";
string strcmd = " SELECT * FROM USER_INFO WHERE USER_NAME = '" + txtusername.Text.Trim() + "' AND USERPWD = '" + txtuserpasswd.Text.Trim() + "'";
OleDbConnection conn = new OleDbConnection(strconn);
OleDbCommand cmd = new OleDbCommand(strcmd, conn);
conn.Open();
userflag = Convert .ToInt32( cmd.ExecuteScalar());
if (userflag > 0)
{
Response.Write("<script>alert(\"登陆成功!\")</script>");
Session["userid"] = txtusername.Text;
Server.Transfer("Default.aspx");
}
else
{
Response.Write("<script>alert(\"密码错误,登录失败!\")</script>");
}
conn.Close();