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. Reverse (2-way) synchronization: DataGridView to Table (Database)

Reverse (2-way) synchronization: DataGridView to Table (Database)

Scheduled Pinned Locked Moved C#
databasehelpquestiondiscussionannouncement
2 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.
  • P Offline
    P Offline
    Paladin2000
    wrote on last edited by
    #1

    I am attempting to accomplish 2-way synch from a DataGridView to a table in my database. DGV to table is easy, but is there a "best practice" way to have the DGV automatically update to reflect any changes made to the database? I tried using a timer and perform a TableAdapter.Fill(DataSet.SomeTable) at regular intervals, but the problem with this approach is that it "clobbers" any edit in progress, and resets the selected row to the top. Preferably, I would avoid impacting the user so directly. Thank you... EDIT: Here is how I am synching DGV changes to the database:

    private void dgvSomeView_RowValidated(object sender, DataGridViewCellEventArgs e)
    {
    myTableAdapter.Update(myDataSet.MyTable);
    }

    P 1 Reply Last reply
    0
    • P Paladin2000

      I am attempting to accomplish 2-way synch from a DataGridView to a table in my database. DGV to table is easy, but is there a "best practice" way to have the DGV automatically update to reflect any changes made to the database? I tried using a timer and perform a TableAdapter.Fill(DataSet.SomeTable) at regular intervals, but the problem with this approach is that it "clobbers" any edit in progress, and resets the selected row to the top. Preferably, I would avoid impacting the user so directly. Thank you... EDIT: Here is how I am synching DGV changes to the database:

      private void dgvSomeView_RowValidated(object sender, DataGridViewCellEventArgs e)
      {
      myTableAdapter.Update(myDataSet.MyTable);
      }

      P Offline
      P Offline
      Paladin2000
      wrote on last edited by
      #2

      I think I found what I need: the SqlDependency class. Looking into it now...

      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