|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Distributed ProgrammingHere 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 Show quoteHide quote "Jon Vaughan" <jonnyvaug***@hotmail.com> schreef in bericht news:0K8og.28499$Bh2.8895@fe07.news.easynews.com... >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 > > 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. Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:Oa56aKemGHA.2112@TK2MSFTNGP04.phx.gbl... > Jon, > > Are you using SQLClient, or OleDB, that use different methods how the > autoincrement Id is handled by the standard dataadapter update. > > Cor > > "Jon Vaughan" <jonnyvaug***@hotmail.com> schreef in bericht > news:0K8og.28499$Bh2.8895@fe07.news.easynews.com... >>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,
See this example, be aware that much of this code can done by the SQLcommandbuilder in such an easy situation as this. See as well that there is not any error handling which completely depends in what way you want to do this: accept already done changes; rollback everything; investigate and let the user make decissions; etc. http://www.vb-tips.com/default.aspx?ID=3405596d-4556-4aa8-be12-d7c12bbb3726 I hope this helps, Cor Show quoteHide quote "Jon Vaughan" <jonnyvaug***@hotmail.com> schreef in bericht news:cB9og.433838$3N6.282827@fe06.news.easynews.com... > 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. > > > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:Oa56aKemGHA.2112@TK2MSFTNGP04.phx.gbl... >> Jon, >> >> Are you using SQLClient, or OleDB, that use different methods how the >> autoincrement Id is handled by the standard dataadapter update. >> >> Cor >> >> "Jon Vaughan" <jonnyvaug***@hotmail.com> schreef in bericht >> news:0K8og.28499$Bh2.8895@fe07.news.easynews.com... >>>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 >>> >>> >> >> > > 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 Show quoteHide quote > 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 > Jim,
Im willing to look at anything , do you have any sample code using GUID's ? Show quoteHide quote "Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message news:24f81e8f39318c867e96d042f04@msnews.microsoft.com... > 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 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 >> > > 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 Show quoteHide quote "Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message news:24f81e8f39318c867e96d042f04@msnews.microsoft.com... > 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 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 >> > >
Dates at Midnight
Rewriting the Textbox Obscure error Registering hot-keys for your Winform DatagridView comboboxcolumn - assign cell value [Regular Expression] match a word with interpunctuation Newbie Needs Help ! VB2003 dll Used in VB2005` Find out the MAC-Adress of a server How to have .net code call pager or phone |
|||||||||||||||||||||||