Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.
-
2012년 8월 9일 목요일 오전 7:20
hi all
I use this code for edit a record
Private Sub btnEdit_Click(sender As System.Object, e As System.EventArgs) Handles btnEdit.Click If Check_ObjectItem() = False Then Exit Sub Using Cmd As New SqlClient.SqlCommand(Nothing, Cn) If Cn.State = ConnectionState.Closed Then Cn.Open() Cmd.CommandText = String.Format("UPDATE ProductActionItem SET UserRef={0},InDate='{1}',Price={2},Total={3},Comment='{4}' WHERE ProductActionItemId={5} ", UserId, Calender.TodayInIran & Space(1) & Now.ToLongTimeString, Double.Parse(txtPrice.Text, Globalization.NumberStyles.Any), Double.Parse(txtTotal.Text, Globalization.NumberStyles.Any), txtComment.Text, dblProductActionItemId) Cmd.ExecuteNonQuery() Cn.Close() End Using With FrmProductAction2 .DataGridViewX2.CurrentRow.Cells(4).Value = Double.Parse(txtPrice.Text, Globalization.NumberStyles.Any) .DataGridViewX2.CurrentRow.Cells(5).Value = Double.Parse(txtTotal.Text, Globalization.NumberStyles.Any) .DataGridViewX2.CurrentRow.Cells(6).Value = txtComment.Text .Sum_Items() .Save_Header_By_Total() .Sum_Debit() End With Me.Close() End Subafter changes record i want to save a new record by this codes...
Private Sub ItemSave() With bsProductActionItem .AddNew() .Current.Item("ProductActionHeaderRef") = 2 & txtProductActionHeaderNum.Text .Current.Item("UserRef") = UserId .Current.Item("InDate") = Calender.TodayInIran & Space(1) & Now.ToLongTimeString If ChkWith.Checked = True Then .Current.Item("InstructionHeaderRef") = txtInstructionHeaderRef.Text .Current.Item("ProductRef") = txtProductRef.Text .Current.Item("Quanty") = txtQuanty.Text .Current.Item("Price") = Double.Parse(txtPrice.Text, Globalization.NumberStyles.Any) .Current.Item("Total") = Double.Parse(txtTotal.Text, Globalization.NumberStyles.Any) If String.IsNullOrEmpty(txtComment.Text.Trim) = False Then .Current.Item("Comment") = txtComment.Text.Trim .EndEdit() End With ProductActionItem2TableAdapter.Update(DsMbsPerlika.ProductActionItem2) EmptyObjectItem() Sum_Items() btnSaveEF.PerformClick() End Sub
but i see an error in this line
ProductActionItem2TableAdapter.Update(DsMbsPerlika.ProductActionItem2)
how to solve this problem
please help me
thanks
Name of Allah, Most Gracious, Most Merciful and He created the human
모든 응답
-
2012년 8월 9일 목요일 오후 1:34
dear BonnieB
Please help me
Name of Allah, Most Gracious, Most Merciful and He created the human
-
2012년 8월 10일 금요일 오전 9:30중재자
Hi sh2013,
Did you get the DsMbsPerlika.ProductActionItem2 before you update the record?
If so, please try to refill the DsMbsPerlika.ProductActionItem2 table before you modify it.
If the issue still not solved, could you please post the insert command of the ProductActionItem2TableAdapter?
Best Regards,
Bob Wu [MSFT]
MSDN Community Support | Feedback to us
- 답변으로 표시됨 Bob Wu-MTMicrosoft Contingent Staff, Moderator 2012년 9월 10일 월요일 오전 11:21

