Saturday, December 15, 2012

Generate a Report from Multiple Databases in ASP.NET


Recently i had a requirement to generate a crystal report from data which retrieved from multiple databases.
In this case what i did was i wrote a method which change the connection string dynamically and retrieve a dataset from each database and finally Merge the data tables using MERGE() method.

Once i have a final dataset with  the data from multiple databases then i could perform the other operations like sorting, searching, and get unique records using below datatable properties.

datatable1.Merge(datatable2);
Merge data tables

datatable1.Sort = "sortExpression";
Sort data table

datatable1.DefaultView.ToTable(true);Get unique records

Finally i could generate a crystal report from the datatable i have generated. You can find a post describing how to bind a datatable to a crystal report here.

No comments:
Write comments
Recommended Posts × +