怎么用vs2010做一个asp登录和注册的网页?谁有具体步骤和相对应的代码,连接sql数据库的那种
怎么用vs2010做一个asp登录和注册的网页?谁有具体步骤和相对应的代码,连接sql数据库的那种!各位大哥大姐帮帮忙!...
怎么用vs2010做一个asp登录和注册的网页?谁有具体步骤和相对应的代码,连接sql数据库的那种!各位大哥大姐帮帮忙!
展开
展开全部
登陆的button中 连接数据库 conn.Open(); string str="select * from biao where name='"+TextBox1.Text+"' and password= '"+TextBox2.Text+"'"; sqlcommand comm=new sqlcommand(str,conn); sqldatareader dr=comm.executereader(); if(dr.read()) {response.write("<script> alert('恭喜成功登陆!‘)</script>");} else { 还是上边那个改成 登陆失败 }
更多追问追答
追答
登陆
string ConnStr = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Database1.mdf;Integrated Security=True;User Instance=True";
SqlConnection conn = new SqlConnection(ConnStr);
conn.Open();
SqlCommand mycomm = new SqlCommand("select * from Table3 ", conn);
SqlDataReader m1;
m1 = mycomm.ExecuteReader();
while (m1.Read())
{
if ((TextBox1.Text.ToString() == m1[0].ToString()) && (TextBox2.Text.ToString() == m1[1].ToString()))
Response.Redirect("WebForm1.aspx");
}
这个也是登陆 protected void Button1_Click(object sender, EventArgs e)
{ string ConnStr = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Database1.mdf;Integrated Security=True;User Instance=True";
SqlConnection conn = new SqlConnection(ConnStr); 连接数据库
conn.Open();
string str = "select * from [userinfo] where Name='"+this.TextBox1.Text+"' and Password='"+this.TextBox2.Text+"'";
SqlCommand com = new SqlCommand(str,conn);
SqlDataReader dr = com.ExecuteReader();
if (dr.Read())
{
Response.Write("alert('恭喜你!登录成功!')");
}
else
{
Response.Write("alert('很遗憾!登录失败!')");
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询