[教程]ASP.NET一个最简单的会员登陆代码
2010/12/22 21:13:00 人气 2380 建站经验区string conn = “server=.;database=login;user id=sa;pwd=123“;*SqlConnection cn = new SqlConnection(conn);*cn.Open();*string strsql = “se lect user_name,user_pwd from admin where user_name=’“ + TextBox1.Text + “’ or user_pwd=’“ + TextBox2.Text + “’“;*Sqlcomm and cmd = new Sqlcomm and(strsql, cn);*SqlDataReader rd = cmd.exe cuteReader();*if (rd.Read())*{*if (rd.GetValue(0).ToString() == TextBox1.Text)*{*if (rd.GetValue(1).ToString() == TextBox2.Text)*{*Response.Redirect(“Default.aspx“);*}*else*{*Response.Write(“<scr ipt>alert(’密码错误!’)</scr ipt>“);*}*}*else*{*Response.Write(“<scr ipt>alert(’用户名错误!’)</scri pt>“);*}*} else*{*Response.Write(“<scr ipt>alert(’用户不存在!’)</scr ipt>“);*}*}
自己走的路自己负责!
暂无回复!
发表回复