题目是:在实验九创建的数据库db_Student中添加一个表t_Users,该表包括以下字段:UserID、UserName、Password、Email和Role。创建一个完整的登录系统,合法用户进入系统, 屏蔽非法用户。
现在我想知道怎么搜索指定的字段的值,用于检查是否和用户输入的信息对应~

解决方案 »

  1.   

    判断他的 帐号和密码 是否对应被简单的 用 select count(*) from t_Users where UserName='111' and Password='111'判断他返回值是否大于0 就知道登录成功没有
      

  2.   

    ?你是什么意思?要做用户验证?在WEB.CONFIG里启用Form验证。
    然后用户登录后可以用SESSION和COOKIE来验证用户合法性
      

  3.   

     。。他返回类型的Object 你转成 int就可以 
      

  4.   

    简单的 用 select count(*) from t_Users where UserName='xxx' and Password='xxx'
    如果要使用role,加上 and role=‘xxx’
      

  5.   


    执行select count(*) from t_Users where UserName='111' and Password='111'
    ExecuteScalar()
      

  6.   

    呵呵  LZ跟我一个班的吧  也做这题呢         thisConnection.Open();            SqlCommand thisCommand = thisConnection.CreateCommand();
                thisCommand.CommandText = "select count(*) from customers";            //ExecuteScalar:执行只返回一个值的SQL命令。
                object countResult = thisCommand.ExecuteScalar();
                Console.WriteLine("Count of Customers={0}",countResult);            Console.ReadLine();            thisConnection.Close();类似的参考下吧  我弄好了