就是先验证数据库里面首先有没有这个用户
然后就是验证密码是否正确
如果都正确,允许进入跳转。最好能够有点源代码,谢谢!!

解决方案 »

  1.   

    高手请指教,我已经通过SqlConnection 连接到数据库了
      

  2.   

    使用sqlcommand,sqldataadapter,dataset这几个类,相关方法:
    sqlcommand.commandtext,connection
    sqldataadapter.selectcommand,fill
    dataset.tables(0).rows(0).item(0)取得密码,验证一下即可
      

  3.   

    楼上的可以说详细点么?我现在就是不会,该如何把select得到的那些元组绑定到变量上去。
      

  4.   

    string strSql="select * from user where user=username and password=password";
    sqlCommand=new sqlcommand(strSql,strConnect);
    sqlRead=sqlCommand.ExecuteRead();
    if(sqlRead.Read())
    {
    //成功
    }
    else
    {
    //失败
    }
    sqlRead.Close();
      

  5.   

    大哥,帮小弟看看哪里有问题。谢谢!!!SqlConnection myConnection = new SqlConnection(myConnectionString);
    SqlCommand myCommand = new SqlCommand("select * from admin where ID="+this.textBox1.Text+"and PsWd = "+this.textBox2.Text);
    myCommand.Connection = myConnection;
    myConnection.Open();
    myCommand.ExecuteNonQuery();
    SqlDataReader myReader;
    myReader = myCommand.ExecuteReader();
    if(myReader.Read())
    MessageBox.Show("OK");
    else MessageBox.Show("error");
    myCommand.Connection.Close();