Я получаю ошибку on (int v2 = cmd1.executenonquery(); ) [system.data.oledb.oledbexception: 'нет значения для одного или нескольких обязательных параметров.']
public partial class Form1 : Form { OleDbConnection con1 = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\User\Desktop\mmA.accdb"); int count1 = 0; OleDbConnection con2 = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\User\Desktop\MA.accdb"); int count2 = 0; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string a = Convert.ToString(textBox1.Text); label2.Text = textBox1.Text.Substring(a.Length - 1); label1.Text = textBox1.Text.Remove(a.Length - 1, 1); count1 = 0; con1.Open(); OleDbCommand cmd1 = con1.CreateCommand(); cmd1.CommandType = CommandType.Text; cmd1.CommandText = "select * from Table1 where mmA='" + label1.Text + "'"; int v1 = cmd1.ExecuteNonQuery(); DataTable dt1 = new DataTable(); OleDbDataAdapter Da1 = new OleDbDataAdapter(cmd1); Da1.Fill(dt1); count1 = Convert.ToInt32(dt1.Rows.Count.ToString()); dataGridView1.DataSource = dt1; con1.Close(); count2 = 0; con2.Open(); OleDbCommand cmd2 = con2.CreateCommand(); cmd2.CommandType = CommandType.Text; cmd2.CommandText = "select * from Table4 where MA='" + label2.Text + "'"; int v2 = cmd1.ExecuteNonQuery(); DataTable dt2 = new DataTable(); OleDbDataAdapter Da2 = new OleDbDataAdapter(cmd2); Da2.Fill(dt2); count2 = Convert.ToInt32(dt2.Rows.Count.ToString()); dataGridView2.DataSource = dt2; con2.Close(); } private void Form1_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'mADataSet.Table4' table. You can move, or remove it, as needed. this.table4TableAdapter.Fill(this.mADataSet.Table4); // TODO: This line of code loads data into the 'mmADataSet.Table1' table. You can move, or remove it, as needed. this.table1TableAdapter.Fill(this.mmADataSet.Table1); } private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null) { dataGridView1.CurrentRow.Selected = true; textBox2.Text = dataGridView1.Rows[e.RowIndex].Cells["mmA"].FormattedValue.ToString(); textBox3.Text = dataGridView1.Rows[e.RowIndex].Cells["cm3A"].FormattedValue.ToString(); } } private void dataGridView2_CellEnter(object sender, DataGridViewCellEventArgs e) { if (dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null) { dataGridView2.CurrentRow.Selected = true; textBox5.Text = dataGridView2.Rows[e.RowIndex].Cells["MA"].FormattedValue.ToString(); textBox6.Text = dataGridView2.Rows[e.RowIndex].Cells["CMA"].FormattedValue.ToString(); } } }
Что я уже пробовал:
пожалуйста, скажи мне, что я делаю не так.Заранее спасибо!