Hello all,
I have the following code in class SQL
But how can I make sure that if the "hasrows" actually returns rows. My form (which is calling on the sql class) gets some kind of a signal. And he knows that the login data is correct and he can send you to the main menu?
The code of the login form is posted below:
Both codes are placed in my login form.
I have the following code in class SQL
Code:
public void ExecuteReadQuery(string ReadQuery)
{
if (dbconn == null)
return;
OleDbDataReader dr;
OleDbCommand cmd = new OleDbCommand();
dr = cmd.ExecuteReader();
if (dr.HasRows == true)
return;
try
{
dbconn.Open();
}
catch (Exception ex)
{
dbconn.Close();
throw new CSMException(ex.Message, ex.Message);
}
finally
{
dbconn.Close();
}
}
The code of the login form is posted below:
Code:
SQL sql = new SQL();
sql.ExecuteReadQuery("SELECT Username, Password FROM Users WHERE Username = "+user + "AND pass = "+pass);
Code:
if ()
{
using (MainMenu MainMenu = new MainMenu())
{
Hide();
MainMenu.ShowDialog();
Environment.Exit(0);
}
}
Comment