"No value given for one or more required parameters" error when working with tabcontrol
Hello,
I have a form with tabcontrol. I want depending on the value in the textBox in the form, to fill the datagridview in the tabcontrol. I wrote this code and got the error:"No value given for one or more required parameters"
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
dateTimePicker2.Focus();
OleDbCommand command3 = new OleDbCommand();
command3.Connection = conn;
command3.CommandText = "SELECT * from Avt where Brdog=?";
command3.Parameters.AddWithValue("@Brgod", textBox1.Text);
conn.Open();
DataSet1 _dataset = new DataSet1();
OleDbDataAdapter oleDbAdapter1 = new OleDbDataAdapter(new OleDbCommand(command3.CommandText, conn));
command3.ExecuteNonQuery();
_dataset.Clear();
oleDbAdapter1.Fill(_dataset, "Avt");
dataGridView1.DataSource = _dataset.Tables["Avt"].DefaultView;
conn.Close();
}
}
But I don't have an idea why I get this error when I give the parameter value in the bold sentence.
Can anybody help me please what could be the problem? Thanks