Concurrency Violation

Magik24

Member
Joined
Apr 11, 2005
Messages
5
Programming Experience
3-5
I get a Concurrency Violation - UpdateCommand affected 0 records when i update a Dataset twice or more

The first time, everything is fine, second time i get the error.

If i refill my dataset with the DataAdapter after every save, everything is fine. But i want to reduce the access to database time, so i dont want reload my dataset each time i do an update ! How can i fix that ?

Im using VB .NET 2003 with Oracle 9I database (OleDB provider for now, upgrading to Oracle Data Provider after i fix this error because i get the same error with the Oracle data provider)

Thank for your help !

Sebastien
 

Magik24

Member
Joined
Apr 11, 2005
Messages
5
Programming Experience
3-5
Here's the UpdateDatasource Sub that i created:

I just send the datatable with the result of GetChange on my Dataset and my Select query to build the CommandBuilder

Private
Sub UpdateDataSource(ByVal ChangedRows As DataTable, ByVal strSQLString AsString)
Dim objOleDbCommand As OleDb.OleDbCommand = New OleDb.OleDbCommand(strSQLString, m_objConnection)

Dim objDataAdapter As New OleDb.OleDbDataAdapter

objDataAdapter.SelectCommand =
New OleDb.OleDbCommand(strSQLString, m_objConnection)

Dim objCommandBuilder AsNew OleDb.OleDbCommandBuilder(objDataAdapter)



If (Not (ChangedRows) Is Nothing) Then



objDataAdapter.Update(ChangedRows)

End If


End Sub


 
Top Bottom