-
December 14th, 2013, 05:08 AM
#1
Concurrency Violation - The update command affected 0 of 1 records
Iam using SQL Server 2012. When I try to save my records it's giving the "Concurrency Violation - The update command affected 0 of 1 records". This error occours only when I save from DataGridView DataSource... Also, once I save to another DataTable and after update, it's working fine. But it's not updating from DataGridView's DataSource.
Thanks For the Guidance’s
// Once I added the below codes, Its' Working fine Since Iam curious, while the error giving only for DGVDtb [ DGV Data Table], but not for NewDtb.
DataTable^ NewDtb = gcnew DataTable();
NewDtb->Columns->Add("emp_id", Type::GetType("System.String"));
NewDtb->Columns->Add("iqama_no", Type::GetType("System.String"));
NewDtb->Columns->Add("iqama_place_iss", Type::GetType("System.String"));
// Then The Data Store to NewDtb, it's working fine... But If I try from DGVDtb it's
not working And giving the Concurrency error for update
InsSavCmd = "Insert into emp_legaldocmst (emp_id,iqama_no,iqama_place_iss) values (@emp_id,@iqama_no,@iqama_place_iss)";
UpdtSavCmd = "Update emp_legaldocmst set iqama_no=@iqama_no,iqama_place_iss=@iqama_place_iss where emp_id=@emp_id";
MyGlobalData::HR_Con->ConnectionString = MyGlobalData::HRCon_1;
MyGlobalData::HR_Con->Open();
SqlTransaction^ Trans = MyGlobalData::HR_Con->BeginTransaction();
MyGlobalData:Ap->UpdateCommand->Transaction = Trans;
MyGlobalData:Ap->InsertCommand->Transaction = Trans;
MyGlobalData:Ap->RowUpdating += gcnew SqlRowUpdatingEventHandler(Form1::OnRowUpdating);
myDataGrid1->CurrentCell = myDataGrid1->FirstDisplayedCell;
myDataGrid1->EndEdit();
try {
MyGlobalData:Ap->Update(DGVDtb);
//MyGlobalData:Ap->Update(NewDtb); **** Its working Fine ***********
Trans->Commit();
MySavMessg="EMPLOYEE LEGAL DOCUMENT MASTER - UPDATE STATUS : SUCCESS";
} catch (System::Exception^ ex) {
MySavMessg="EMPLOYEE LEGAL DOCUMENT MASTER HAS NOT UPDATED : STATUS - FAIL : " +ex->Message;
}
MyGlobalData::HR_Con->Close();
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|