확인하는 동안 안녕하세요 저는 DGV를 업데이트하려면 다음 코드를 사용하고 있습니다 :DataGridView에 동시성 위반
private void propertyInformationDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (propertyInformationDataGridView.IsCurrentCellDirty && e.ColumnIndex.ToString() != "3")
{
propertyInformationTableAdapter.Update((newCityCollectionDataSet)propertyInformationBindingSource.DataSource);
}
}
그리고이 코드를 DGV를 업데이트하고 특정 테이블에 값을 전달 :
private void propertyInformationDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex.ToString() == "3")
{
DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)propertyInformationDataGridView.Rows[e.RowIndex].Cells[3];
DataGridViewRow row = propertyInformationDataGridView.Rows[e.RowIndex] as DataGridViewRow;
System.Data.DataRowView SelectedRowView;
newCityCollectionDataSet.PropertyInformationRow SelectedRow;
SelectedRowView = (System.Data.DataRowView)propertyInformationBindingSource.Current;
SelectedRow = (newCityCollectionDataSet.PropertyInformationRow)SelectedRowView.Row;
if (Convert.ToBoolean(checkCell.Value) == false && propertyInformationDataGridView.IsCurrentCellDirty)
{
DataClasses1DataContext dc = new DataClasses1DataContext();
var matchedCaseNumber = (from c in dc.GetTable<PropertyInformation>()
where c.CaseNumberKey == SelectedRow.CaseNumberKey
select c).SingleOrDefault();
DateTime saveNow = DateTime.Now;
reportsSent newReport = new reportsSent();
newReport.CaseNumberKey = SelectedRow.CaseNumberKey;
dc.reportsSents.InsertOnSubmit(newReport);
matchedCaseNumber.DateFinished = saveNow;
dc.SubmitChanges();
}
}
}
은 어떻게됩니까 값을 완료하거나 cellvalue 3을 클릭 한 다음 다른 셀에서 인스턴스 값 0의 다른 셀을 클릭하면 오류가 발생합니다. 나는 왜 내가 오류를 얻고 있는지 이해하지만 이것을 막기 위해 어떻게 갈 것인가? 오류가 발생하지 않도록이 코드를 유효성 검사에서 클릭으로 이동해야하나요? 아니면이 문제를 해결할 다른 방법이 있습니까? 나는이 함께 업데이트하고 있기 때문에 오류가 발생하는 이유는 다음과 같습니다 dc.SubmitChanges();
를 한 후 다시 여기 업데이트 :
if (propertyInformationDataGridView.IsCurrentCellDirty && e.ColumnIndex.ToString() != "3")
{
propertyInformationTableAdapter.Update((newCityCollectionDataSet)propertyInformationBindingSource.DataSource);
}
나는 경우가 완료된 후 바로 데이터 세트의 업데이트가 강제하는 방법을 잘 모르겠습니다.
오류는 다음과 같습니다
동시성 위반이 다음 UpdateCommand가 예상 한 기록의 영에 영향을 미쳤다. 디자이너에서
는 여기까지 보여줍니다
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
[global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]
public virtual int Update(newCityCollectionDataSet dataSet) {
return this.Adapter.Update(dataSet, "PropertyInformation");
감사합니다,
코
항상 질문에 오류 메시지의 문구를 포함하십시오. –