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. General Programming
  3. C#
  4. undo changes on table in database

undo changes on table in database

Scheduled Pinned Locked Moved C#
csharpdatabaseasp-netsql-serverdesign
3 Posts 3 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.
  • H Offline
    H Offline
    Hanan888
    wrote on last edited by
    #1

    my application has the following procedure. a database of products (20,000 rows) exists. our client has 'import' feature where he imports an excel file. this is implemented by deleting all products table rows, then doing the import - which is a long thing since we programmatically performing calculations on the data. the obvious problem is if the 'import' action fails (IO stuff), they now have none/partial/curropt data in the products table. We wish that if the 'import' operation fails, the original data remains. this is ASP.NET application, written in C#, using SQL Server 2005 and using XSD which we created through the VS2005 design tools.

    L L 2 Replies Last reply
    0
    • H Hanan888

      my application has the following procedure. a database of products (20,000 rows) exists. our client has 'import' feature where he imports an excel file. this is implemented by deleting all products table rows, then doing the import - which is a long thing since we programmatically performing calculations on the data. the obvious problem is if the 'import' action fails (IO stuff), they now have none/partial/curropt data in the products table. We wish that if the 'import' operation fails, the original data remains. this is ASP.NET application, written in C#, using SQL Server 2005 and using XSD which we created through the VS2005 design tools.

      L Offline
      L Offline
      Lev Danielyan
      wrote on last edited by
      #2

      You can use transactions and roll back in case of errors. Try googling[^] around

      Regards, Lev

      1 Reply Last reply
      0
      • H Hanan888

        my application has the following procedure. a database of products (20,000 rows) exists. our client has 'import' feature where he imports an excel file. this is implemented by deleting all products table rows, then doing the import - which is a long thing since we programmatically performing calculations on the data. the obvious problem is if the 'import' action fails (IO stuff), they now have none/partial/curropt data in the products table. We wish that if the 'import' operation fails, the original data remains. this is ASP.NET application, written in C#, using SQL Server 2005 and using XSD which we created through the VS2005 design tools.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3
        1. Make a copy of the table that the stuff gets imported to. Ensure that this table is empty. 2) Import all your stuff to the secondary table 3) If there are no exceptions then delete everything in the original import-table, and copy all stuff from the secondary table to the import-table. If an exception did occur, the original import-table will still hold all data. You could also use transactions to achieve a similar functionality. SQL Server caches all changes that way, in order to 'undo' them. I don't know which of these options would serve you best. The transaction-approach would probably be faster to implement.

        I are troll :)

        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