So, I'm making a small application for my company, letting users login and access specific data, however, on the server side, which queries the database, the MySqlDataReader doesnt read, as I pointed out in the following code:
public string HandleLogin(string uname, string pwd)
{
MySqlDataReader READER;
int count = 0;
int clearance = 0;
if (uname == "" || pwd == "")
return "";
CONN = new MySqlConnection();
CONN.ConnectionString = Config.CONNSTRING;
string query = "select * from members where username='" + uname + "' and password='" + pwd + "'";
try
{
CONN.Open();
COMMAND = new MySqlCommand(query, CONN);
READER = COMMAND.ExecuteReader();
while(READER.Read())
{
count = count + 1; //<-- this should happen, but it doesnt
if (count == 1)
clearance = READER.GetInt32("clearance");
else
return "";
}
if (count == 1)
return Convert.ToString(clearance);
else
return "";
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
return "";
}
finally
{
CONN.Dispose();
}
}
I am sure it should read 1 row, asking the amount of rows it found, it said 0, but I triple checked all the values and they match the database values exactly, but it reads no rows for the query. This might be a very stupid mistake but I'm not able to find the problem.