|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
TableAdapter does not refresh after updateusing optimistic concurrency. When I insert a new row, or update an exsting row, the TableAdapter doesn't get refreshed even though the final line in the stored procedures are select statements that return the modified row. Everything that I have found indicates the select statement should trigger the refresh, but it the refresh does not occur and subsequent edits or deletions to the row fail. The failure to refresh the data is not just an issue with the application that I am attempting writing. At first I thought it might be happening because a timestamp column is used for concurrency, but that doesn't appear to be the issue. I tried the C# example code from the multiple table walkthrough at http://msdn2.microsoft.com/en-us/library/4esb49b4.aspx and the same thing happens. The first update works, but subsequent updates to the same row fail because the TableAdapter does not get refreshed. This was not apparent when I first ran the application, so I deleted the row I added and tried again. After the save, the order showed the same ID value that was generated by the client when adding it to the DataGridView. The correct id was not displayed until I exiting and restarted the application. It appears that the multiple table example failed to included the necessary
call to Merge() required to update the DataTable ith the data returned by the select statement which follows the insert/update. Unfortunately, while adding the Merge() statement showed the newly retieved data, but it also appends a new row to the table rather than updating the existing one with the correct key. The result was 1 broken row followed by 1 working row. Thanks to http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=184395&SiteID=1 I have been able to get this issue resolved also. Apparently, the key is to not use GetChanges() which returns a DataTable but Select() which returns an array of DataRows. Show quote "Calvin Westervelt" wrote: > I have a DataGridView bound to a TableAdapter with which I am updating data > using optimistic concurrency. When I insert a new row, or update an exsting > row, the TableAdapter doesn't get refreshed even though the final line in the > stored procedures are select statements that return the modified row. > Everything that I have found indicates the select statement should trigger > the refresh, but it the refresh does not occur and subsequent edits or > deletions to the row fail. > > The failure to refresh the data is not just an issue with the application > that I am attempting writing. At first I thought it might be happening > because a timestamp column is used for concurrency, but that doesn't appear > to be the issue. I tried the C# example code from the multiple table > walkthrough at http://msdn2.microsoft.com/en-us/library/4esb49b4.aspx and the > same thing happens. The first update works, but subsequent updates to the > same row fail because the TableAdapter does not get refreshed. This was not > apparent when I first ran the application, so I deleted the row I added and > tried again. After the save, the order showed the same ID value that was > generated by the client when adding it to the DataGridView. The correct id > was not displayed until I exiting and restarted the application. |
|||||||||||||||||||||||