Hi MB,
Thanks for your steps to reproduce the problem. It makes things easier for
me to debug, and I have found the cause of the DBConcurrencyException.
I reproduced the problem with 2 trials of updating. The first time we
update the data source, the new value is written. Then the trigger comes
up. It modifies the ChangedDate field of that record. When the second
update fires, the DataAdapter found that the record in data source has been
changed, so an DBConcurrencyException was thrown.
To avoid this, we have to refresh the data in application after each
update. Here is a code snippet which refreshes the single row by the
primary key.
Private Sub UpdateRow(ByVal TableName As String, ByVal ID As String)
'Get a reference to the specified row
Dim dr As DataRow = dsAllData.Tables(TableName).Rows.Find(ID)
'Create a Command update to pull the new underlying data
Dim cmd As New SqlClient.SqlCommand("SELECT * FROM " & TableName & _
" WHERE ID=" & ID, connCustSvc)
'Open the connection and create the DataReader
connCustSvc.Open()
Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader()
rdr.Read()
'Copy the new data from the database to the DataRow
Dim dc As DataColumn
For Each dc In dr.Table.Columns
If dc.ReadOnly = False Then _
dr.Item(dc.ColumnName) = rdr.Item(dc.ColumnName)
Next
'Accept changes in the DataRow
dr.AcceptChanges()
connCustSvc.Close()
End Sub
For more information about tackling data concurrency exceptions using the
dataSet object, please check the following article. It is a good article
which explains the cause of difference concurrency issue for you.
http://msdn.microsoft.com/msdnmag/is...y/default.aspx
HTH. If anything is unclear, please feel free to reply to the post.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."