am working in C# on ADO.NET, i connected with my database successfully and everything is fine so i put check in side while(reader.Read) to check specefic value but the condition is giving false everytime i try,
string qry = "select * from LoginTB";
reader = db.select_data(qry);
while (reader.Read())
{
MessageBox.Show(reader["ID"].ToString());// its shows Doctor
if (string.Equals(reader["ID"].ToString(), "Doctor"))// why false?!
{
//flag = true;
MessageBox.Show("hello");
str = reader[2].ToString();
break;
}
}
You probably have whitespace at one end or another.
Try changing your MessageBox call to surround the string with quotation marks, or add a .Trim to the comparison: