笨方法之一OleDbDataReader
------------------------------
OleDbCommand myCommand = new OleDbCommand("SELECT * FROM t_user where t_Uname= '"+ t_Uname.Text +"' and t_Upwd ='"+ t_Upwd.Text +"' and i_id=1 ",myConn);
myConn.Open();
OleDbDataReader myReader = myCommand.ExecuteReader();
if (myReader.HasRows == false){ ..........
}
------------------------------
OleDbCommand myCommand = new OleDbCommand("SELECT * FROM t_user where t_Uname= '"+ t_Uname.Text +"' and t_Upwd ='"+ t_Upwd.Text +"' and i_id=1 ",myConn);
myConn.Open();
OleDbDataReader myReader = myCommand.ExecuteReader();
if (myReader.HasRows == false){ ..........
}
DataSet的名字==null
因为这个DataSet可能本身就是空的,没有表,这样的情况下用Tables[0]保准出错。
要判断你的记录集合是否为空需要视你的代码的实际情况来说,方法非常多。
总结就是
1。trycatch
2。DataSet==null
3。DataTable。rows。count == 0(这个很可能需要先判断其DataSet是否为空)
……