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. Reflecting the changes to main table.

Reflecting the changes to main table.

Scheduled Pinned Locked Moved C#
csharpasp-netdotnetquestionannouncement
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.
  • J Offline
    J Offline
    jdkulkarni
    wrote on last edited by
    #1

    Hello All, I am developing an application with DataGridView. I have provided paging for it. What I am doing is, get the records in one main table, let the user set the page size and copy those many records to temp table. User can insert, update and delete records from using DataGridView. Now my concern is, user is playing with temp table, whatever he does is modified into temp table. I want to reflect added, changed or deleted data into original main table. I have tried Merge() but it adds all modified data into main table and when I say adapter.Update(maintable) it gives primary key violation. Any idea or workaround:(?

    Jayant D. Kulkarni Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET

    M 1 Reply Last reply
    0
    • J jdkulkarni

      Hello All, I am developing an application with DataGridView. I have provided paging for it. What I am doing is, get the records in one main table, let the user set the page size and copy those many records to temp table. User can insert, update and delete records from using DataGridView. Now my concern is, user is playing with temp table, whatever he does is modified into temp table. I want to reflect added, changed or deleted data into original main table. I have tried Merge() but it adds all modified data into main table and when I say adapter.Update(maintable) it gives primary key violation. Any idea or workaround:(?

      Jayant D. Kulkarni Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET

      M Offline
      M Offline
      MIHAI_MTZ
      wrote on last edited by
      #2

      what happens if you call adapter.Update(temp) ?

      J 1 Reply Last reply
      0
      • M MIHAI_MTZ

        what happens if you call adapter.Update(temp) ?

        J Offline
        J Offline
        jdkulkarni
        wrote on last edited by
        #3

        Adapter.Update calls insert, update, delete in subsequent manner. Hence when I call Adapter.Update(dataTable) it throws primary key constraint failed or unique key constraints failed exception. I tried to remove some rows from main table and then again adding. But it also not working.:(

        Jayant D. Kulkarni Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET

        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