Answer the question
In order to leave comments, you need to log in
What data type should be in the selection condition expression?
What is the problem that does not allow writing to the database?
System.Data.OleDb.OleDbException: "Data type mismatch in selection condition expression."
private void Button2_Click(object sender, EventArgs e)
{
OleDbConnection Base3 = new OleDbConnection
(@"Provider= Microsoft.JET.OLEDB.4.0;Data Source=C:\Users\MaKsi\Desktop\Диплом\baza.mdb");
Base3.Open();
OleDbDataAdapter Adapter3 = new OleDbDataAdapter
("UPDATE [Продукты] SET [Наименование] = \"" + textBox4.Text + "\",[Колличество] = \"" + textBox5.Text + "\",[Дата] = \"" + dateTimePicker2.Value.ToString("dd.MM.yyyy") + "\" WHERE [Код] = \"" + textBox3.Text + "\"", Base3);
DataTable Table3 = new DataTable();
Adapter3.Fill(Table3);
Base3.Close();
OleDbConnection Base4 = new OleDbConnection
(@"Provider= Microsoft.JET.OLEDB.4.0;Data Source=C:\Users\MaKsi\Desktop\Диплом\baza.mdb");
Base4.Open();
OleDbDataAdapter Adapter4 = new OleDbDataAdapter
("SELECT * FROM Продукты", Base4);
DataTable Table4 = new DataTable();
Adapter4.Fill(Table4);
dataGridView1.DataSource = Table4;
Base4.Close();
}
Answer the question
In order to leave comments, you need to log in
OleDbConnection Base3 = new OleDbConnection
(@"Provider= Microsoft.JET.OLEDB.4.0;Data Source=C:\Users\MaKsi\Desktop\Диплом\baza.mdb");
Base3.Open();
OleDbDataAdapter Adapter3 = new OleDbDataAdapter
("UPDATE Продукты SET Наименование = \"" + textBox4.Text + "\", Количество = \"" + textBox5.Text + "\", Дата = \"" + dateTimePicker2.Value.ToString("dd.MM.yyyy") + "\" WHERE Код = " + textBox3.Text + "", Base3);
DataTable Table3 = new DataTable();
Adapter3.Fill(Table3);
Base3.Close();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question