websofter
@websofter
Programmer...

Добавить строку данных в Access через .NET. Не работает код, кто найдет ошибку?

Подскажите пожалуйста, что я не так делаю? Постоянно выдает , что у меня ошибка в INSERT, но не могу врубиться где? Таблица с ключевым полем.

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("Данные удачно добавлены. Перезагрузите таблицу, чтобы увидеть результат!");
  • Вопрос задан
  • 2396 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы