新手:asp.net登陆验证问题

来源:百度知道 编辑:UC知道 时间:2024/05/15 01:32:10
asp.net登陆验证代码是什么,也就是输入帐号密码的登陆验证,最好是简短的代码,有与数据操作教程的网站请给我一个。
private void Button1_Click(object sender, System.EventArgs e)
{
conn = new SqlConnection("server=.;database=pass;uid=sa;pwd=");
sql = "select usid,pwd from pass where usid='"+this.TextBox1.Text.Trim()+"' and pwd='"+this.TextBox2.Text.Trim()+"'";
da = new SqlDataAdapter(sql,conn);
ds = new DataSet();
da.Fill(ds);

if(这里应该怎么判断用户名和密码是否相同啊!我记得前面是什么什么==0)
{
Response.Redirect("main.aspx");
}
else
{
this.Label1.Text="密码错误";
}
}

高手教一下

using System.Security.Cryptography;
using System.Text;

protected int IsPass(string str1,string str2)
{
string cl1 = str1;
string cl2 = str2;
string pwd = "";
MD5 md5 = MD5.Create();
string LinkBefore = ConfigurationSettings.AppSettings["LinkBefore"];
string LinkAfter = ConfigurationSettings.AppSettings["LinkAfter"];
string ConnectionString = LinkBefore + Server.MapPath(LinkAfter);
conn = new OleDbConnection(ConnectionString);
// 加密后是一个字节类型的数组
byte[] s=md5.ComputeHash(Encoding.Unicode.GetBytes(cl2));
// 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得
for(int i = 0 ; i < s.Length; i++)
{
// 将得到的字符串使用十六进制类型格式。格式后的字符是小写的字母,如果使用大写(X)则格式后的字符是大写字符
pwd = pwd + s[i].ToString("x");
}
string cardpass = "Select count(*) From [bgpwt] Where [UserName]=@UserName And [Pass]=@PassWord";
OleDb