I got a project for school and I wanted to create a login form in visual studio. This error appeared. How can I solve this? on the OleDbDataReader rdr = cmd.ExecuteReader(); i got the System.Data.OleDb.OleDbException: 'No value given for one or more required parameters. error and i have no idea why because it is the same as another project that worked. My database is in the bin folder of the project. Help me
OleDbConnection con = new OleDbConnection();
public Autentificare()
{
InitializeComponent();
con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Environment.CurrentDirectory + @"\Librarie.accdb";
}
private void buttonautentificare_Click(object sender, EventArgs e)
{
if (textBoxparola.Text != "" && textBoxid.Text != "")
{
con.Open();
int ct = 0, id = 0;
string sql = "select ID_client from Clienti where Parola='" + textBoxparola.Text + "' and E-mail='" + textBoxid.Text + "'";
OleDbCommand cmd = new OleDbCommand(sql, con);
OleDbDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
ct++;
id = int.Parse(rdr[0].ToString());
}
if (ct>0)
{
MessageBox.Show("Autentificare cu succes!");
Optiuni f = new Optiuni(id);
this.Hide();
f.ShowDialog();
con.Close();
}
else
{
MessageBox.Show("Date incorecte!");
textBoxid.Text = textBoxparola.Text = "";
con.Close();
}
}
}
} }