Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Select and update selected data

Select and update selected data

Scheduled Pinned Locked Moved Database
databasecsharpsharepointsql-serversysadmin
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vipin d
    wrote on last edited by
    #1

    Hi, I am using MSSQL 2000 and MS.NET 2.0 I have some doubt.My requirment is I need to select some data (ie status=3) from webserver's database and insert it into my local machine's Database.Table structure in both server are same.And at the same time i need to update the status of the selected rows to 4. Now my idea is, a class contain two functions.One is for DownloadWeb and other is InsertLocal. The DownloadWeb return a dataset(selected data) and InsertLocal insert the the table in dataset to local database. My doubt is where i place "update status=4" query.. I write one sp in my webserver like BEGIN TRANSACTION BEGIN SELECT data END BEGIN UPDATE status=4 END IF @@ERROR <> 0 BEGIN -- Rollback the transaction ROLLBACK RETURN -1 END COMMIT or any other idea???? Be very grateful for any advice. Regards

    They laugh at me; they think I’m different. I laugh at them, ‘coz they are all same
    CrazySanker

    J 1 Reply Last reply
    0
    • V Vipin d

      Hi, I am using MSSQL 2000 and MS.NET 2.0 I have some doubt.My requirment is I need to select some data (ie status=3) from webserver's database and insert it into my local machine's Database.Table structure in both server are same.And at the same time i need to update the status of the selected rows to 4. Now my idea is, a class contain two functions.One is for DownloadWeb and other is InsertLocal. The DownloadWeb return a dataset(selected data) and InsertLocal insert the the table in dataset to local database. My doubt is where i place "update status=4" query.. I write one sp in my webserver like BEGIN TRANSACTION BEGIN SELECT data END BEGIN UPDATE status=4 END IF @@ERROR <> 0 BEGIN -- Rollback the transaction ROLLBACK RETURN -1 END COMMIT or any other idea???? Be very grateful for any advice. Regards

      They laugh at me; they think I’m different. I laugh at them, ‘coz they are all same
      CrazySanker

      J Offline
      J Offline
      John ph
      wrote on last edited by
      #2

      what if the Sql Transaction (Insert) to Local Server fails? You can't Rollback the Update transaction happened on the other SQLServer. what about this alternative(using ADO.NET SQLTransaction object)? 1. DownLoadWeb (select data from Server1) 2. InsertLocal (Insert data to Server2) - SQLTransaction object 3. UpdateStatus (update Status in Server1) Use a SQLTransaction object for the Insert operation. make sure (2) and (3) are successfull and then commit the transaction otherwise Rollback.

      Regards
       - J O H N -


      V 1 Reply Last reply
      0
      • J John ph

        what if the Sql Transaction (Insert) to Local Server fails? You can't Rollback the Update transaction happened on the other SQLServer. what about this alternative(using ADO.NET SQLTransaction object)? 1. DownLoadWeb (select data from Server1) 2. InsertLocal (Insert data to Server2) - SQLTransaction object 3. UpdateStatus (update Status in Server1) Use a SQLTransaction object for the Insert operation. make sure (2) and (3) are successfull and then commit the transaction otherwise Rollback.

        Regards
         - J O H N -


        V Offline
        V Offline
        Vipin d
        wrote on last edited by
        #3

        Thank you so much.. let me check the SQLTransaction object..

        They laugh at me; they think I’m different. I laugh at them, ‘coz they are all same!!
        CrazySanker

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups