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. Visual Basic
  4. saving table

saving table

Scheduled Pinned Locked Moved Visual Basic
helpquestionannouncement
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.
  • C Offline
    C Offline
    cj4331
    wrote on last edited by
    #1

    I load an excel spreadsheet via oledb driver into a datatable. I fill in some blank fields. Now I want to save the changes. I tried using a commandbuilder and issuing myExcelAdapter.Update(myExcelDt) but I got an error that it couldn't generate an update command for a table with out a key field. No new records were added and none were deleted. I just want to overwrite or update the spreadsheet with the copy in the datatable as it has some fields that were blank filled in now. How is the best way to accomplish this?

    C 1 Reply Last reply
    0
    • C cj4331

      I load an excel spreadsheet via oledb driver into a datatable. I fill in some blank fields. Now I want to save the changes. I tried using a commandbuilder and issuing myExcelAdapter.Update(myExcelDt) but I got an error that it couldn't generate an update command for a table with out a key field. No new records were added and none were deleted. I just want to overwrite or update the spreadsheet with the copy in the datatable as it has some fields that were blank filled in now. How is the best way to accomplish this?

      C Offline
      C Offline
      cj4331
      wrote on last edited by
      #2

      It would seem if I want to update a record I will have to do it with a custom sql command for each record I want to update. As there is no key fields in the excel table I have no idea how to specify and update command either. I guess that is why the command builder couldn't come up with anything. I thought about deleting all the records in the excel database and writing back all the modified records from the datatable but then I read that the jet engine would not allow me to delete records from an excel db so I didn't even bother to try. My only choice now as far as I can see is remote control of excel or building another excel table and adding the records to that. I do not wish to do remote control of excel. It all would have been so much easier if I could have stayed connected to the excel spreadsheet read the record looked up the necessary data and written changes to the records then done a skip to get the next record and repeat. :sigh:

      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