Distributed Programming

  • Thread starter Thread starter Jon Vaughan
  • Start date Start date
J

Jon Vaughan

I have a program that uses disconnected recordsets on the client side :

Here is the problem I have :

Client gets a dataset , say a customer table

Creates a new customer
Deletes this customer

Updates changes to server.

The server code detects that a record has been deleted via rowstate, takes
the new ID of the deleted record ( generated by the client side table via
setting autoincrement to true and setting the seed to the last ID + 1).

Now this causes 2 problems :

1.) It doesnt need to delete as it was only a client side record create and
deleted and therefore isnt on the sevrer.
2.) What happens if another user creates a record that is given the newly
created local ID that is the same as the one that im trying to delete.

Basically I have a problem with my distributed programming methodology. Can
someone point me to the right way to handle this ?

Thanks
 
Jon,

Are you using SQLClient, or OleDB, that use different methods how the
autoincrement Id is handled by the standard dataadapter update.

Cor
 
Here is my dataaccess class sample code :



Dim cn As New SqlConnection(Connections.Value)

Dim cm As New SqlCommand("sp_here", cn)

......

cm.ExecuteNonQuery()



I presume that is SQLClient, the code is then passed into this sub via a
dataset, values are extracted from the ds and loaded into the parameters.



Hope this is the info you are looking for.
 
If you use guids rather than Ints as your primary key, the problem will go
away (of course, that would likely require more redesign than you want to
undertake). That's one of the reasons why I use entity classes rather than
datasets. I can still have the data persistance as integers to the database,
but the internal collections use Guids for binding with the UI. I also have
code on the update that detects if a deleted entity is new and then doesn't
worry about issuing the update statement. It takes more up-front coding,
but I find it more maintainable down the road.

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
 
I have seent his and I cna see this being a solution without to much
reworking :

Private Function getGUID() As String
GetGUID = "{" & _
System.Guid.NewGUID().ToString & "}"
End Function

Thanks all
 
Back
Top