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. Updates wrong table in dataset

Updates wrong table in dataset

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

    Hello,

               System.Data.OleDb.OleDbCommandBuilder cb = new System.Data.OleDb.OleDbCommandBuilder(dAdapter);
               
                if (current\_list == "list1")
               {
                   DataRow row = myset.Tables\["list"\].NewRow();
                       
                   int y;
                   y = myset.Tables\["list"\].Rows.Count;
    
                   row\["ID"\] = y + 1;
                   row\["word"\] = s; // s is user input
                   row\["perc"\] = 0.5;
                   
                    myset.Tables\["list"\].Rows.Add(row);
                   
                   dAdapter.Update(myset, "list");
                  
               } 
    

    I used break points to confirm that the data is updated here, however, for some reason when I check the database another table is updated instead of "list" Where could be the problem? I checked the code several times, but I'm not sure :confused:

    P 1 Reply Last reply
    0
    • S Star09

      Hello,

                 System.Data.OleDb.OleDbCommandBuilder cb = new System.Data.OleDb.OleDbCommandBuilder(dAdapter);
                 
                  if (current\_list == "list1")
                 {
                     DataRow row = myset.Tables\["list"\].NewRow();
                         
                     int y;
                     y = myset.Tables\["list"\].Rows.Count;
      
                     row\["ID"\] = y + 1;
                     row\["word"\] = s; // s is user input
                     row\["perc"\] = 0.5;
                     
                      myset.Tables\["list"\].Rows.Add(row);
                     
                     dAdapter.Update(myset, "list");
                    
                 } 
      

      I used break points to confirm that the data is updated here, however, for some reason when I check the database another table is updated instead of "list" Where could be the problem? I checked the code several times, but I'm not sure :confused:

      P Offline
      P Offline
      Paulo Zemek
      wrote on last edited by
      #2

      I don't use dataadapters or datatables, for me they are legacy. But, how is the command of the dataadapter built? If you pass a custom SQL to the data-adapter (I really don't know if this is the case), that could be the cause, not the code block you showed here, as here the data adapter already exists.

      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