if exists (select 用户名, 密码 from 用户表 
             where 用户名 = :txtUserID and 密码 = :txtPsw)
begin
   print '正确'
   ......
end
else
   print '错误'
   ......
end

解决方案 »

  1.   

    在btnOK的Click()事件中写访问数据库的代码。用select语句,如果返回为空则用户不存在。
      

  2.   

    tj_dns(愉快的登山者)的方式有问题,不要用。select 用户名, 密码 from 用户表 where 用户名 = '"+txtUserID.text+"'"if(记录数==1)
        if(密码字段==输入的密码) 
               return 正确;
    return 错误;
      

  3.   

    //Sql 
    string strQuery="select * from where 用户名="+txtUerID.Text+" and 密码="+txtPsw.Text;//Execute strQuery
    SqlConnection myConnection = new SqlConnection(myConnString);
    SqlCommand myCommand = new SqlCommand(mySelectQuery,myConnection);
    myConnection.Open();
    SqlDataReader myReader;
    myReader = myCommand.ExecuteReader();if(myReader.Read()) 
    {
          //用户名和密码正确       
    }
    else
    {
          //用户名和密码错误       
    }// always call Close when done reading.
    myReader.Close();
    // Close the connection when done with it.
    myConnection.Close();