I don't know what DB you're using. I mostly use Oracle so I use Oracle sequences to handle this problem. It's pretty straightforward. The client can assign whatever pk ID it wants, but when it sends the data back up to the webservice to be committed to the DB, the webservice reassigns the ID to MYTABLE_SEQ.NEXTVAL or whatever. I believe a similar approach can be taken in SQL Server with Autoincrement ID's or some such nonsense. :)
This can be tricky, though, if the client is adding records in other tables that refer to this ID. Then it's a matter of making the webservice intelligent enough to update all the referring records to the proper ID. GUIDs may be another solution for you, as Mr. Blewett suggests, but I don't have any real world experience doing that. HTH, Stuart Laughlin www.bistrotech.net > -----Original Message----- > From: Bill Bassler [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 04, 2004 8:46 AM > To: [EMAIL PROTECTED] > Subject: [ADVANCED-DOTNET] Ensuring unique keys from multiple > DataSets when updating > > > I'm designing an application that has a server running a > webservice that supplies a dataset through one method, and > accepts changes through another. The dataset supplied has a > primary key on the only one table it contains. Now, two > clients, "A" and "B", request the dataset, here is how their > table looks (Identical). > > CustomerID FirstName > 1 Alpha > 2 Beta > > Both "A" and "B" add a row. Since the primary key generated > by the datasets could be identical or irrelevant, how do I > ensure that the database generates a consistent primary key? > > =================================== > This list is hosted by DevelopMentor(r) http://www.develop.com > Some .NET courses you may be interested in: > > NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles > http://www.develop.com/courses/gaspdotnetls > > View archives > and manage your subscription(s) at http://discuss.develop.com > =================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com
