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;
  }
I wrote the code in my data access layer but it was giving error on rows to count the columns.
Error:
'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?)
 
     
     
     
     
    