form验证+asp.net+c#+数据库的实例源码

添加人:wuzheworld一级(224分)   添加时间:2008-06-14    阅读次数:338  收藏此教程
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>"); 
  }
1页 第1上一页1下一页
相关的教程: form验证
收藏此教程

当前平均分: 0.0(0 次打分)

-5-4-3-2-1012345
评论主题
您的大名
您的评论
验证码 点击换一个验证码
知识库搜索: