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. Sync between a local and remote Dataset

Sync between a local and remote Dataset

Scheduled Pinned Locked Moved C#
announcementdatabaseperformancehelp
3 Posts 1 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.
  • A Offline
    A Offline
    Are Jay
    wrote on last edited by
    #1

    I am looking for an help in the best way to accomplish a sync between two dataset of the same type. Meaning I have a LOCAL and REMOTE version of the database and I'm needing to sync them nightly. I have a web service that will accept a dataset and update the REMOTE version but because of a large amount of data I have a LOCAL copy that represents the REMOTE version. I first parse in data from flat files into a RAW virsion and need to sync data between the RAW and LOCAL versions, ( RAW will trump the LOCAL). I then use a web service to pass ONLY the changed data to the REMOTE version of the database. Overall I'm looking of and easy, processor and memory friendly way to sync this data. Any and all ideas on the topic would be helpful.

    I'm listening but I only speak GEEK.

    A 2 Replies Last reply
    0
    • A Are Jay

      I am looking for an help in the best way to accomplish a sync between two dataset of the same type. Meaning I have a LOCAL and REMOTE version of the database and I'm needing to sync them nightly. I have a web service that will accept a dataset and update the REMOTE version but because of a large amount of data I have a LOCAL copy that represents the REMOTE version. I first parse in data from flat files into a RAW virsion and need to sync data between the RAW and LOCAL versions, ( RAW will trump the LOCAL). I then use a web service to pass ONLY the changed data to the REMOTE version of the database. Overall I'm looking of and easy, processor and memory friendly way to sync this data. Any and all ideas on the topic would be helpful.

      I'm listening but I only speak GEEK.

      A Offline
      A Offline
      Are Jay
      wrote on last edited by
      #2

      foreach ( dsLogPro.CompaniesRow row_Raw in ds_Raw.Companies.Rows ) { dsLogPro.CompaniesRow found_Local = ds_Local.Companies.FindByCompanyCode( row_Raw.CompanyCode ); if ( found_Local != null ) { if ( !found_Local.Equals( row_Raw ) ) { // raw will trump local foreach ( DataColumn col in ds_Local.Companies.Columns ) { found_Local[ col ] = row_Raw[ col ]; // update local with raw } } } else { // this must be a new row found_Local = ds_Local.Companies.NewCompaniesRow(); foreach ( DataColumn col in ds_Local.Companies.Columns ) { found_Local[ col ] = row_Raw[ col ]; // update local with raw } ds_Local.Companies.Rows.Add( found_Local ); } } This is the direction I'm currently moving towards. I don't believe the tables will change but the columns might change in the future so I'm really trying to keep this flexable. I'm listening but I only speak GEEK.

      1 Reply Last reply
      0
      • A Are Jay

        I am looking for an help in the best way to accomplish a sync between two dataset of the same type. Meaning I have a LOCAL and REMOTE version of the database and I'm needing to sync them nightly. I have a web service that will accept a dataset and update the REMOTE version but because of a large amount of data I have a LOCAL copy that represents the REMOTE version. I first parse in data from flat files into a RAW virsion and need to sync data between the RAW and LOCAL versions, ( RAW will trump the LOCAL). I then use a web service to pass ONLY the changed data to the REMOTE version of the database. Overall I'm looking of and easy, processor and memory friendly way to sync this data. Any and all ideas on the topic would be helpful.

        I'm listening but I only speak GEEK.

        A Offline
        A Offline
        Are Jay
        wrote on last edited by
        #3

        private void CompaniesCompare() { rowsAdded = 0; rowsDeleted = 0; rowsUpdated = 0; start = DateTime.Now; // This will update and add the rows m_parentProcess.OnPostMessageEventHandler( this, new MigrationEventArgs( "\tcomparing company data." ) ); foreach ( dsLogPro.CompaniesRow row_Raw in ds_Raw.Companies.Rows ) { dsLogPro.CompaniesRow found_Local = ds_Local.Companies.FindByCompanyCode( row_Raw.CompanyCode ); if ( found_Local != null ) { if ( !found_Local.Equals( row_Raw ) ) { // raw will trump local foreach ( DataColumn col in ds_Local.Companies.Columns ) { found_Local[ col ] = row_Raw[ col ]; // update local with raw } rowsUpdated++; } } else { // this must be a new row found_Local = ds_Local.Companies.NewCompaniesRow(); foreach ( DataColumn col in ds_Local.Companies.Columns ) { found_Local[ col ] = row_Raw[ col ]; // update local with raw } ds_Local.Companies.Rows.Add( found_Local ); rowsAdded++; } UpdateProgressBar(); } // This will remove un-needed rows foreach ( dsLogPro.CompaniesRow row_Local in ds_Local.Companies.Rows ) { dsLogPro_Live.CompaniesRow found_Raw = ds_Raw.Companies.FindByCompanyCode( row_Local.CompanyCode ); if ( found_Raw == null ) { // was not present in the raw so remove it. ds_Local.Companies.Rows.Remove( row_Local ); rowsDeleted++; } UpdateProgressBar(); } } This is what I have ended up with and would like someone elses opinion on the code. I'm listening but I only speak GEEK.

        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