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. Need help with TableAdapter problem [modified]

Need help with TableAdapter problem [modified]

Scheduled Pinned Locked Moved C#
databasehelpcsssql-serversysadmin
4 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.
  • K Offline
    K Offline
    kensai
    wrote on last edited by
    #1

    Solved: I realized I'm a huge dummy and forgot a transaction I wrapped around delete operation. Turns out I forgot to add a trans.Complete() at the end of it. I added it and problem solved. I have a typed DataSet mapping a local SQL Server CE 3.5 .sdf file using DataGridView on a WinForm. I can successfully add and modify data but for some reason I can't delete any. I don't get any errors either. Can you please give me any ideas about what could be wrong? I can't figure this out and I'd appreciate any help. I use simple methods like this:

    fill
    myTableTableAdapter.Fill(myDataSet.MyTable);

    add
    (after adding new row to grid also to bindingsource)
    myTableTableAdapter.Update(myDataSet.MyTable);

    delete
    myDataSet.MyTableRow row = myDataSet.MyTable.FindByID(id);
    row.Delete();
    myTableTableAdapter.Update(myDataSet.MyTable);

    The row is gone from gridview. I also check myDataSet.MyTable parameter in myTableTableAdapter.Update(myDataSet.MyTable) using debug visualizer, it's is gone from there too (row status: Deleted). But when I refill data from database, it's back like nothing happend.. I checked DeleteCommand of the myTableTableAdapter, it is defined and correct. I don't copy project database file over the newer build file either. I wrote a simple log to see the rowstatus of the row. Everything seems to work as it should but still the row comes back after a db refill:

    Log: row status: Unchanged
    Log: calling row.Delete()
    Log: row status: Deleted
    Log: entering Update() function
    Log: row status: Deleted
    Log: calling tableAdapter.Update(dataset.Table)
    Log: row status: row not found in dataset

    Any ideas?

    modified on Tuesday, May 26, 2009 6:12 AM

    F K 2 Replies Last reply
    0
    • K kensai

      Solved: I realized I'm a huge dummy and forgot a transaction I wrapped around delete operation. Turns out I forgot to add a trans.Complete() at the end of it. I added it and problem solved. I have a typed DataSet mapping a local SQL Server CE 3.5 .sdf file using DataGridView on a WinForm. I can successfully add and modify data but for some reason I can't delete any. I don't get any errors either. Can you please give me any ideas about what could be wrong? I can't figure this out and I'd appreciate any help. I use simple methods like this:

      fill
      myTableTableAdapter.Fill(myDataSet.MyTable);

      add
      (after adding new row to grid also to bindingsource)
      myTableTableAdapter.Update(myDataSet.MyTable);

      delete
      myDataSet.MyTableRow row = myDataSet.MyTable.FindByID(id);
      row.Delete();
      myTableTableAdapter.Update(myDataSet.MyTable);

      The row is gone from gridview. I also check myDataSet.MyTable parameter in myTableTableAdapter.Update(myDataSet.MyTable) using debug visualizer, it's is gone from there too (row status: Deleted). But when I refill data from database, it's back like nothing happend.. I checked DeleteCommand of the myTableTableAdapter, it is defined and correct. I don't copy project database file over the newer build file either. I wrote a simple log to see the rowstatus of the row. Everything seems to work as it should but still the row comes back after a db refill:

      Log: row status: Unchanged
      Log: calling row.Delete()
      Log: row status: Deleted
      Log: entering Update() function
      Log: row status: Deleted
      Log: calling tableAdapter.Update(dataset.Table)
      Log: row status: row not found in dataset

      Any ideas?

      modified on Tuesday, May 26, 2009 6:12 AM

      F Offline
      F Offline
      Fahad Sadah
      wrote on last edited by
      #2

      Does the delete work in T-SQL?

      K 1 Reply Last reply
      0
      • F Fahad Sadah

        Does the delete work in T-SQL?

        K Offline
        K Offline
        kensai
        wrote on last edited by
        #3

        Yes I can delete with sql. I added a query to table adapter and I can delete records using it. However I'm trying to create a fully disconnected application so I really would like to solve this delete problem. Any ideas?

        1 Reply Last reply
        0
        • K kensai

          Solved: I realized I'm a huge dummy and forgot a transaction I wrapped around delete operation. Turns out I forgot to add a trans.Complete() at the end of it. I added it and problem solved. I have a typed DataSet mapping a local SQL Server CE 3.5 .sdf file using DataGridView on a WinForm. I can successfully add and modify data but for some reason I can't delete any. I don't get any errors either. Can you please give me any ideas about what could be wrong? I can't figure this out and I'd appreciate any help. I use simple methods like this:

          fill
          myTableTableAdapter.Fill(myDataSet.MyTable);

          add
          (after adding new row to grid also to bindingsource)
          myTableTableAdapter.Update(myDataSet.MyTable);

          delete
          myDataSet.MyTableRow row = myDataSet.MyTable.FindByID(id);
          row.Delete();
          myTableTableAdapter.Update(myDataSet.MyTable);

          The row is gone from gridview. I also check myDataSet.MyTable parameter in myTableTableAdapter.Update(myDataSet.MyTable) using debug visualizer, it's is gone from there too (row status: Deleted). But when I refill data from database, it's back like nothing happend.. I checked DeleteCommand of the myTableTableAdapter, it is defined and correct. I don't copy project database file over the newer build file either. I wrote a simple log to see the rowstatus of the row. Everything seems to work as it should but still the row comes back after a db refill:

          Log: row status: Unchanged
          Log: calling row.Delete()
          Log: row status: Deleted
          Log: entering Update() function
          Log: row status: Deleted
          Log: calling tableAdapter.Update(dataset.Table)
          Log: row status: row not found in dataset

          Any ideas?

          modified on Tuesday, May 26, 2009 6:12 AM

          K Offline
          K Offline
          kensai
          wrote on last edited by
          #4

          Alright, problem solved. I realized I'm a huge dummy and forgot a transaction I wrapped around delete operation. Turns out I forgot to add a trans.Complete() at the end of it. I added it and problem solved.

          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