mike Delvotti

mike Delvotti

  • NA
  • 262
  • 0

Handle null on checking DB

Aug 25 2011 1:13 PM
I'm having some real issues with handling a null reference when checking my database for a username and password on the below code.

If the username and password match it works, but if it doesn't or the username + password textboxes are empty it throws a null execption?

How can I handle the null on the below?

if (strResult.Length == 0)
   {
               
      label1.Text = "INCORRECT USER/PASS!";
         }
   else
   {
              
    label1.Text = "YOU ARE LOGGED IN!";
       }
}

Answers (2)