Error:
System. ArgumentException: "This list cannot be cleared."
Code:
- private void button3_Click(object sender, EventArgs e)
- {
- if ((textBox2.Text != "") ||
- (textBox3.Text != "") ||
- (textBox4.Text != "") ||
- (textBox5.Text != "") ||
- (textBox10.Text != "") ||
- (textBox8.Text != ""))
- {
- if (radioButton1.Checked == false & radioButton2.Checked == false) { radioButton1.Checked = true; }
- dataGridView1.Rows.Clear();
- string type = "";
- string name = "";
- string weight = "";
- string company = "";
- string client = "";
- string price = "";
- string log = "";
- int y = 0;
- if (radioButton2.Checked == true) { log = "OR "; }
- if (radioButton1.Checked == true) { log = "AND "; }
- if (textBox2.Text != "")
- {
- type = "??? = '" + textBox2.Text + "'"; y = 1;
- }
- if (textBox3.Text != "")
- {
- if (y == 1) { name = "" + log + "???????????? = '" + textBox4.Text + "'"; } else { name = "???????????? = '" + textBox4.Text + "'"; y = 1; }
- }
- if (textBox3.Text != "")
- {
- if (y == 1) { weight = "" + log + "??? = " + textBox4.Text + ""; } else { weight = "??? = " + textBox4.Text + ""; y = 1; }
- }
- if (textBox5.Text != "")
- {
- if (y == 1) { company = "" + log + "????? = '" + textBox5.Text + "'"; } else { company = "????? = '" + textBox5.Text + "'"; y = 1; }
- }
- if (textBox10.Text != "")
- {
- if (y == 1) { client = "" + log + "?????????? = '" + textBox10.Text + "'"; } else { client = "?????????? = '" + textBox10.Text + "'"; y = 1; }
- }
- if (textBox8.Text != "")
- {
- if (y == 1) { price = "" + log + "???? = " + textBox8.Text + ""; } else { price = "???? = " + textBox8.Text + ""; y = 1; }
- }
- string query = "SELECT ???, ????????????, ???, ?????, ??????????, ???? FROM ??????? WHERE " + type + name + weight + company + client + price + "";
- Form2 form2 = new Form2();
- OleDbCommand command = new OleDbCommand(query, form2.Connection);
- OleDbDataReader reader = command.ExecuteReader();
- while (reader.Read())
- {
- dataGridView1.Rows.Add(
- reader[0].ToString(),
- reader[1].ToString(),
- reader[2].ToString(),
- reader[3].ToString(),
- reader[4].ToString(),
- reader[5].ToString());
- }
- reader.Close();
- }
- else
- {
- MessageBox.Show("?? ?????? ?? ?????!");
- }
- }