Distributed Programming

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Vaughan

    #1

    Distributed Programming

    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


  • Cor Ligthert [MVP]

    #2
    Re: Distributed Programming

    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" <jonnyvaughan@h otmail.com> schreef in bericht
    news:0K8og.2849 9$Bh2.8895@fe07 .news.easynews. com...[color=blue]
    >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
    >
    >[/color]


    Comment

    • Jon Vaughan

      #3
      Re: Distributed Programming

      Here is my dataaccess class sample code :



      Dim cn As New SqlConnection(C onnections.Valu e)

      Dim cm As New SqlCommand("sp_ here", cn)

      ......

      cm.ExecuteNonQu ery()



      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]" <notmyfirstname @planet.nl> wrote in message
      news:Oa56aKemGH A.2112@TK2MSFTN GP04.phx.gbl...[color=blue]
      > 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" <jonnyvaughan@h otmail.com> schreef in bericht
      > news:0K8og.2849 9$Bh2.8895@fe07 .news.easynews. com...[color=green]
      >>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
      >>
      >>[/color]
      >
      >[/color]


      Comment

      • Jim Wooley

        #4
        Re: Distributed Programming

        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

        [color=blue]
        > 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
        >[/color]


        Comment

        • Jon Vaughan

          #5
          Re: Distributed Programming

          Jim,

          Im willing to look at anything , do you have any sample code using GUID's ?


          "Jim Wooley" <jimNOSPAMwoole y@hotmail.com> wrote in message
          news:24f81e8f39 318c867e96d042f 04@msnews.micro soft.com...[color=blue]
          > 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
          >[color=green]
          >> 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
          >>[/color]
          >
          >[/color]


          Comment

          • Jon Vaughan

            #6
            Re: Distributed Programming

            I have seent his and I cna see this being a solution without to much
            reworking :

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

            Thanks all

            "Jim Wooley" <jimNOSPAMwoole y@hotmail.com> wrote in message
            news:24f81e8f39 318c867e96d042f 04@msnews.micro soft.com...[color=blue]
            > 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
            >[color=green]
            >> 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
            >>[/color]
            >
            >[/color]


            Comment

            • Cor Ligthert [MVP]

              #7
              Re: Distributed Programming

              Jon,

              See this example, be aware that much of this code can done by the
              SQLcommandbuild er 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.



              I hope this helps,

              Cor

              "Jon Vaughan" <jonnyvaughan@h otmail.com> schreef in bericht
              news:cB9og.4338 38$3N6.282827@f e06.news.easyne ws.com...[color=blue]
              > Here is my dataaccess class sample code :
              >
              >
              >
              > Dim cn As New SqlConnection(C onnections.Valu e)
              >
              > Dim cm As New SqlCommand("sp_ here", cn)
              >
              > .....
              >
              > cm.ExecuteNonQu ery()
              >
              >
              >
              > 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]" <notmyfirstname @planet.nl> wrote in message
              > news:Oa56aKemGH A.2112@TK2MSFTN GP04.phx.gbl...[color=green]
              >> 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" <jonnyvaughan@h otmail.com> schreef in bericht
              >> news:0K8og.2849 9$Bh2.8895@fe07 .news.easynews. com...[color=darkred]
              >>>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
              >>>
              >>>[/color]
              >>
              >>[/color]
              >
              >[/color]


              Comment

              Working...