I'm writing a plug-in for another program that generates a fairly complex tree structure of objects. The users will need to export this data from the plug-in for analysis and reporting. I definitely want them to be able to export to an MS Access database as it would be the most accessible for them to create quick and clean reports. But I also would like to set things up so it would be easy to export to other data sources (XLS, XML, SQL Server etc..) with out a lot of duplicate code.
I have created recursive methods that will populate various DataTables from the tree structure. I can then stuff these DataTables into a DataSet. But at that point I'm kinda lost.
All the examples I find for ADO.NET start with having some central data source. Then you create a DataConnection to the data through the correct DataProvider using a connection string. After which you can get out either a DataReader or DataSet depending on whether you need to save changed back to the source.
Yet I'm starting with the DataSet, and need to create a data source from it. Is there some easy reusable way that I could create a new DataConnection based on some existing empty data source, and then populate it with my DataSet?
For example I could create a DataConnection to an empty MS Access file. Then I could use my recursive methods to populate various DataTables in a DataSet from my tree structure. But how could I populate the blank access database with this resulting DataSet?
I'm hoping for a method that is generic enough so that I can easily export to different potential data sources by simply swapping in different DataProviders and/or connection strings.