Answer the question
In order to leave comments, you need to log in
Add a row of data to Access via .NET. The code does not work, who will find the error?
Please tell me what am I doing wrong? It constantly gives out that I have an error in INSERT, but I can’t figure out where? Table with key field.
connect = gcnew System::Data::OleDb::OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=btiDB.mdb;Persist Security Info=False");
connect->Open();
System::Data::OleDb::OleDbCommand^ command =
gcnew System::Data::OleDb::OleDbCommand("INSERT INTO Заявки ("+
"[NumberClaim]" + "," +
"[Adress]" + "," +
"[District]" + "," +
"[DateStart]" + "," +
"[Inspector]" + "," +
"[Timer]" + "," +
"[DateWorker]" + "," +
"[IDClient]" + "," +
"[IDChief]" + "," +
"[IDHelper]" + "," +
"[IDPay]" +
") VALUES(" +
"@NumberClaim," +
"@Adress," +
"@District," +
"@DateStart," +
"@Inspector," +
"@Timer," +
"@DateWorker," +
"@IDClient," +
"@IDChief," +
"@IDHelper," +
"@IDPay)", connect);
command->Parameters->Add("@NumberClaim", OleDbType::Integer)->Value = tbNumberClaim->Text;
//command->Parameters["@NumberClaim"]->Value = tbNumberClaim->Text;
command->Parameters->Add("@Adress", OleDbType::VarChar)->Value = tbAdress->Text;
//command->Parameters["@Adress"]->Value = tbAdress->Text;
command->Parameters->Add("@District", OleDbType::VarChar)->Value = tbDistrict->Text;
//command->Parameters["@District"]->Value = tbDistrict->Text;
command->Parameters->Add("@DateStart", OleDbType::Date)->Value = dpDateStart->Value;
//command->Parameters["@DateStart"]->Value = dpDateStart->Value;
command->Parameters->Add("@Inspector", OleDbType::Date)->Value = dpInspector->Value;
//command->Parameters["@Inspector"]->Value = dpInspector->Value;
command->Parameters->Add("@Timer", OleDbType::VarChar)->Value = tbTime->Text;
// command->Parameters["@Timer"]->Value = tbTime->Text;
command->Parameters->Add("@DateWorker", OleDbType::Date)->Value = dpDateWorker->Value;
//command->Parameters["@DateWorker"]->Value = dpDateWorker->Value;
command->Parameters->Add("@IDClient", OleDbType::Integer)->Value = cbIDClient->SelectedValue;
//command->Parameters["@IDClient"]->Value = cbIDClient->SelectedValue;
command->Parameters->Add("@IDChief", OleDbType::Integer)->Value = cbIDChief->SelectedValue;
//command->Parameters["@IDChief"]->Value = cbIDChief->SelectedValue;
command->Parameters->Add("@IDHelper", OleDbType::Integer)->Value = cbIDHelper->SelectedValue;
//command->Parameters["@IDHelper"]->Value = cbIDHelper->SelectedValue;
command->Parameters->Add("@IDPay", OleDbType::Integer)->Value = cbIDPay->SelectedValue;
//command->Parameters["@IDPay"]->Value = cbIDPay->SelectedValue;
command->ExecuteReader();
MessageBox::Show("Данные удачно добавлены. Перезагрузите таблицу, чтобы увидеть результат!");
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question