Newb Timestamp Question

The One Who Was

Well-known member
Joined
Jun 2, 2003
Messages
52
Location
Manitoba Canada
Greetings:

Im looking for a way to fix some concurrency issues with my VB project. Id like for a user to be prompted with an error for each row that has already be modified by another user...

my issue is, I do no know now to compare each row in the dataset to its old value. My guess would be to create a new dataset, fill it, then compare the changes from the old dataset with the new one. Lets say my user has just made a bunch of changes to the current dataset named DatasetOld


Sub UpdateRows()
Dim dsNewTemp as New Dataset
Dim dsChanges as New Dataset

SqlDataAdatper1.Fill(dsNewTemp)

dsChanges = DatasetOld.GetChanges
.....
.....
.....
End Sub


Now that dsChanges has the changed values and dsNewTemp has the old data, how would I go about writing code that would loop line for line examining the time stamp and primary key and posting errors for the lines that were changes by someone else??

I apologize for my inexperience. With all the advantages Ive found with ado.net this has been so far the biggest disadvantage for me.

Thank you in advance to anyone who has taken the time to read this. You help is most appreciated.

~~The One Who Was~~
 
I dont have much experience with DataAdapter, but I believe you can use an UPDATE command to update all modified rows where the timestamp is the same. If a row is not able to be updated, then it automatically sets that row with an error (I could be wrong, double check this somewhere).

So your UPDATE command would look something like this;

UPDATE table SET values=values WHERE uniqueid=uniqueid AND timestamp = timestamp

If the row was updated by another user, then obviously the timestamp would be incorrect and the row would not be able to update because it cannot find the unique id and timestamp match. This *should* automatically set that specified row as having an error (which you can check with HasErrors, I do believe a DataGrid will also auto show errors if its bound to the row).
 
Back
Top