private void SignIn_Click(object sender, EventArgs e)
{
try
{
string constring = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\project SMS\School management\School Management System\DB\Schoolmanagmentsystem.accdb";
string cmdText= "select count(*) from User Where UserName= ?and [Password]=?" ;
using (OleDbConnection con = new OleDbConnection(constring))
using (OleDbCommand cmd = new OleDbCommand(cmdText, con))
{
con.Open();
cmd.Parameters.AddWithValue("@p1", UesrNameTextBox.Text);
cmd.Parameters.AddWithValue("@p2", passwordTextBox.Text); // <- is this a variable or a textbox?
int result = (int)cmd.ExecuteScalar();
if (result > 0)
MessageBox.Show("Login Successful");
else
MessageBox.Show("Invalid Credentials, Please Re-Enter");
con.Close();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}