private void btnLogin_Click(object sender, EventArgs e)
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = "select * from Cafelist where Username = '" + txtUsn.Text + "' and Password = '" + txtPass.Text + "'";
OleDbDataReader reader = command.ExecuteReader();
int count = 0;
while (reader.Read())
{
count = count + 1;
}
if(count ==1)
{
MessageBox.Show("Username and password is correct");
}
else if (count > 1)
{
MessageBox.Show("Duplicate Found");
}
else
{
MessageBox.Show("Username/Password Incorrect");
}
connection.Close();
}
trying to use this code to pull usn and pass for login, and get this error, tried looking around for a solution but haven't found any similar to my issue, i understand this is probably something really basic but please go easy as i've only been playing around with c# a couple weeks and this is my first attempt at using databases.
not trying to do any security features just trying to work out why when i enter text and click login this error appears, i have been following a youtube video try and self teach (as much as you can with this subject) however he doesn't hit this error and i have googled myself into oblivion.
thanks in advance, anymore information required let me know as this is my first time posting.