关于登陆的一个小问题×××××××××
关于一个登陆页面按钮后置代码   
 要求和数据库比较用户名&密码。。 
 正确就转向一个页面,错误就返回登陆页 
 其它的都不要    
 哪位老大帮忙写个(包括数据库连接之类的) 
       protected   void   ImageButton1_Click(object   sender,   ImageClickEventArgs   e) 
             { 
 }   
 按钮事件的代码。。 
 本人刚学习。见笑了
------解决方案--------------------using System.Data; 
 using System.Data.SqlClient;   
 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) 
   { 
     if(nametxtbox.Text.Trim()!= " " && pwdtxtBox.Text.Trim()!= " ") 
     {  
 	ConnectSql(nametxtbox.Text.Trim(),pwdtxtBox.Text.Trim()); 
     } 
   } 
   private void ConnectSql(string username,string pwd) 
   { 
    IDbConnection conn = null; 
    try 
    { 
     conn = new SqlConnection( "server=localhost;uid=sa;pwd=;database=UserDB "); 
     conn.Open(); 
     string mySel= "select * from [user] where name= ' "+username+ " ' "; 
     SqlCommand com = new SqlCommand(mySel, (SqlConnection)conn); 
     SqlDataReader reader = com.ExecuteReader(); 
     if(!reader.HasRows) 
     { 
      Response.Redirect( "index.aspx?error=用户名错误 "); 
     } 
     else 
     { 
      while(reader.Read()) 
      { 
       if(pwd!=reader.GetString(2)) 
        Response.Redirect( "index.aspx?error=密码错误 "); 
       else 
        Response.Redirect( "Main.html "); 
      } 
     } 
    } 
    catch(SqlException) 
    { 
     Response.Write( "在打开连接时出现连接级别的错误! "); 
    } 
    finally 
    { 
     if(conn != null) 
      conn.Close(); 
    }