I noticed that when I get to the line

if (usrNmeLbl.Text == usr)

that if the database couldn't get the username to match to an existing user that that check of the usr at that if statement will be skipped. I guess because of an unseen error from the reader that it just handles itself. I see that I need to do a check sooner as to whether the usr matches the textbox name. I am guessing I must somehow check that the paramater @usrnmeLbl is returning a value other than null? If so, how? Or some other way?



SqlCommand comm = new SqlCommand("SELECT * FROM UsrTbl, RelativeTable, IP_Table WHERE RelativeTable.UserID IN (SELECT UserID FROM UsrTbl WHERE UserName = @usrnmeLbl)", conn);
comm.Parameters.AddWithValue("@usrnmeLbl", usrNmeLbl.Text);
conn.Open();
SqlDataReader reader = comm.ExecuteReader();
while (reader.Read())
{
string usr = reader["UserName"].ToString();
usr = usr.TrimEnd();
string pss = reader["Password"].ToString();
pss = pss.TrimEnd();
if (usrNmeLbl.Text == usr)

I ask this because if I do an else for my if statement, the if is never reached under this condition and the else never gets triggered.

Thanks so much in advance.