form验证+asp.net+c#+数据库的实例源码
config---------------> 
   
  <authentication  mode="Forms"  >   
  <forms  loginUrl="login.aspx"></forms> 
  </authentication> 
  <authorization> 
  <deny  users="?"/> 
  </authorization> 
   
  .CS-----------------> 
   
  string  UserName=this.TextBox1.Text.Trim(); 
  string  Pass=this.Textbox2.Text.Trim(); 
  SqlConnection  Mycon=new  SqlConnection(server=(local);DataBase=jdp;User  ID=sa;Pwd=;Timeout=900"); 
  string  Sql="select  UserName,Pass  from  dbo.UserInfo  where  UserName='"+UserName+"'and  Pass='"+Pass+"'"; 
   
  SqlDataAdapter  Dat=new  SqlDataAdapter(Sql,Mycon); 
  DataTable  Dt=new  DataTable(); 
  Dat.Fill(Dt); 
  if(Dt.Rows.Count>0) 
  { 
   
  FormsAuthentication.RedirectFromLoginPage(UserName,false); 
  Response.Redirect("default.aspx?User="+this.TextBox1.Text.Trim()); 
  } 
  else 
  { 
  Response.Write("<script>alert('你输入的密码错误!')</script>"); 
  }

相关文章:

  • 2021-08-13
  • 2021-07-28
  • 2022-02-27
  • 2021-08-24
猜你喜欢
  • 2021-10-15
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-04-30
相关资源
相似解决方案