The application allows users to add new records to the dataset and then update the datasource. The update datasource call writes the new rows to SQL Server with no problems. However, quite oftern when the update datasource happens the identity field creatred in the dataset has already been allocated (someone else added a record at same time).
Now, things are still OK as SQL Server will happily add the record, but now the identity field allocated by sql Server is different to the one in my original dataset.
How do I get my original dataset to show the revised identity field generated by SQL Server?
I know you can get the value using @.@.IDENTITY but how do I get that back into the dataset?Try using the SCOPE_IDENTITY function instead of @.@.IDENTITY. It has a narrower scope, so you should get back the value you want.
Don|||Getting the revised value isnt the problem.
The isssue is how do I reflect that back into the orignal dataset.
The only way I can see to do this is process additions to the datasource separately from updates and after each insert, fetch the revised IDENTITY field and then write a load of code to examine the new datasource generated value, compare it with the value originally created by the dataset and if it differs, then change the dataset value.
That make sense?