I want to check if my query returns any value or not and write the remaining logic accordingly.
SqlCommand myCommand = new SqlCommand("Select * from phc.userbase where [user]='@Username' and [password]='@password'", myConnection);
I want to know this command returns null or not. I tried
myReader = myCommand.ExecuteReader();
bool rd = myReader.Read();
if rd==false
but I can't get it working. Any ideas?
Here are my parameters:
SqlParameter myParam = new SqlParameter("@Username", SqlDbType.VarChar, 25);
myParam.Value = usr;
SqlParameter myParam2 = new SqlParameter("@password", SqlDbType.VarChar, 25);
myParam2.Value = pass;
'@Username'with a password of'@Password'- which is very different to checking whether they have a username the same as the value of the parameter@Username. I bet that query always returns zero rows, right?[user] = @Username and [password] = @password- look - no quotes!