I've got a basic Database in C# which is created dynamically in a separate class. I am able to populate the database but I'm not so sure how to read the data from it to allow authentication
The database is on Microsoft Access.
I've tried using sql data adaptor (maybe this is wrong), and I think I need to make it so the SQL executed is a query (Currently, the command.ExecuteNonQuery();
is in action
private void btn_login_Click(object sender, EventArgs e)
{
string Username = txt_loginusername.Text;
string UserPassword = txt_loginpassword.Text;
string _SqlString = "SELECT * FROM Users WHERE Username='" + Username + "' AND UserPassword='" + UserPassword + "'";
SqlDataAdapter sd = new SqlDataAdapter(_SqlString, Database.CONNECTION_STRING);
DataTable dt = new DataTable();
sd.Fill(dt);
if(dt.Rows.Count == 1)
{
FrmMain FrmMain = new FrmMain();
this.Hide();
FrmMain.Show();
}
else
{
MessageBox.Show("Error");
}
}