- 博客(0)
- 资源 (5)
- 收藏
- 关注
asp.net登陆源码
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string myStr = ConfigurationManager.ConnectionStrings["DataBaseConnectionString4"].ToString();
SqlConnection myConn = new SqlConnection(myStr);
SqlCommand myCmd = new SqlCommand("select count(*) from Users where loginName=@loginName and loginPasswrod=@loginPwd", myConn);
myCmd.Parameters.Add(new SqlParameter("@loginName", SqlDbType.VarChar, 20));
myCmd.Parameters["@loginName"].Value = TextBox1.Text ;
myCmd.Parameters.Add(new SqlParameter("@loginPwd", SqlDbType.VarChar, 50));
myCmd.Parameters["@loginPwd"].Value = TextBox2 .Text;
myConn.Open();
int i = (int)myCmd.ExecuteScalar();
myCmd.Dispose();
myConn.Close();
if (i != 0)
{
Response.Redirect("Default.aspx");
}
else
{
Response.Write("<script>alert('用户名和密码不存在!请重新登录!');</script>");
}
}
2011-05-04
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人