saving table
-
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?
-
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?
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: