用户登录是最常用,最基本的. protected void BtnOK_Click(object sender, EventArgs e) { SqlConnection cn = new SqlConnection(@"data source=(local);user id=sa;password=;initial catalog=database;integrated security=sspi"); cn.Open(); string sqlstr = "select [Name],[Password] from [database] where [Name]='" + TxtUser.Text + "' and Password='" + TxtPassword.Text + "'; SqlCommand cm = new SqlCommand(sqlstr, cn); SqlDataReader dr = cm.ExecuteReader(); if (dr.Read()) { Session["Name"] = dr["Name"]; Response.Redirect("web.aspx"); } else { Response.Write("登录失败!"); } //cn.Close; }
一个简单的登录问题
最新推荐文章于 2021-06-16 14:38:29 发布