public bool ValidateUser(string uName)
{
SqlCommand cmd = new SqlCommand();
if (connection == null)
{
connection = connectToDB();
}
cmd.Connection = connection;
cmd.CommandText = "Select * from Users where UserName='" + uName + "'";
cmd.CommandType = CommandType.Text;
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
if (dr.Rows.Count > 0)
{
return true;
}
else
{
return false;
}
데이터 액세스 계층에 코드를 작성했지만 행 수를 계산할 때 오류가 발생했습니다.SqlDataReader의 행 누락 속성이 누락되었습니다.
오류 :
'System.Data.SqlClient.SqlDataReader' does not contain a definition for 'Rows' and no extension method 'Rows' accepting a first argument of type 'System.Data.SqlClient.SqlDataReader' could be found (are you missing a using directive or an assembly reference?)
어떤 오류가 발생 했나요? –
오류 'System.Data.SqlClient.SqlDataReader'에 '행'및 확장 메서드 정의가 없습니다. 'System.Data.SqlClient.SqlDataReader'형식의 첫 번째 인수를 수락하는 '행'을 찾을 수 있습니다. using 지시문이나 어셈블리 참조가 누락 되었습니까?) –