用select命令对sql进行访问查找相关数据,查询成功或失败后返回值是什么啊?

解决方案 »

  1.   

    查询失败是抛出错误,只有底层的Driver才返回错误号不同数据库的错误号都不大一样的
      

  2.   

    查询失败后,程序就会出错,可以使用 try 语句来处理错误
      

  3.   

    这个要看你的验证密码的sql怎么写了如果是select * from user where username = 'billgates' and userpwd='*******'
    帐号密码正确的话返回有记录
    不正确返回没有记录如果是select count(*) from user where username = 'billgates' and userpwd='*******'
    帐号密码正确的话返回1(或更多,原则上应该是1)
    不正确返回0
      

  4.   

    ListBox1.Items.Add(newSqlComm.ExecuteNonQuery().ToString());
    返回1就有0就是没有
      

  5.   

    newSqlComm = new SqlCommand("select count(*) from user where username = 'billgates' and userpwd='*******'",conn);
    if(int.Parse(newSqlComm.ExecuteScalar().tostring())==1)
         有这个人
    else
         没这个人