The task was straightforward, or so I thought; create a small application that transfers an applications configuration information from the test database into the production database (before go-live!!). I chose to create a windows application using C# and ADO.NET, I thought that it would be so ridiculously simple that I didn't think I needed objects\frameworks.
The steps are simple and few:
Simple?!?! I could retrieve the data (into a DataTable) and knew I could use the DataAdapter's 'Update' function to then insert the data into the destination database, but no matter what I tried I could not get it to work. There were no errors, the DataTable was full of data, the 'Update' function was called but nothing was going into the database...
After a lot of wasted time searching the internet, and trying a lot of different things (trial and error), a colleague pointed me towards another blog written by WATYF <http://www.musicalnerdery.com/nerdery/copying-data-from-one-database-to-another-using-adonet.html>! Finally someone trying to do exactly what I was trying to do.
As it turns out, none of the flags had been set as 'modified' or 'added', thus there was nothing to update. Even though I had retrieved the data from one connection and was sending it to a completely different connection, it was still looking at that flag!
When retrieving the data, you need to set 'AcceptChangesDuringFill' flag to false. Then all of the rows in the DataTable are flagged as new, and will be inserted.
Huge thanks to WATYF, for pointing me in the right direction.