Hey
I made an application that generates reports based on data from a database. The functionality of my application is correct, but I have a following problem: my client has 2 identical databases - one for testing and one for actual work he does. My application should work with both databases (it should have a "switching mechanism"), but I don't know how to implement it. I know that I could just switch between connection strings but the problem is that in my reports I use datasets that are bound to one database. Is it possible to fill those datasets with the data from both databases (since the databases are identical in schema, it should be possible), and how would that be done, or do I have to use duplicate dataset/report pairs?
I'm using C# in VS 2010 with SQL Server 2005, and .rdlc for my reports.
Thanks.
Loading
VulpesPosted Mar 1, 2012, 7:03 AM
http://msdn.microsoft.com/en-us/library/system.data.datatable.merge.aspx
Otherwise, you could try to get the second DataAdapter to fill the DataTable already created by the first DataAdapter. However, I suspect that either it won't work at all, it will work but the existing rows will be overwritten or it will appear to work but you'll end up with a mess when you try to write updates back to the relevant sources.
Neven DraskovicPosted Mar 1, 2012, 6:35 AM
Thanks
VulpesPosted Mar 1, 2012, 6:18 AM
Each database needs to fill its own DataTable(s) within the DataSet so updates can be posted back to the correct source.
There's an example below on MSDN which should get you on the right track:
http://msdn.microsoft.com/en-us/library/bh8kx08z.aspx