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.
What I did was, 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 you have a final dataset with  the data from multiple databases then you can perform the other operations like sorting, searching, and get unique records using below datatable properties.

Merge data tables

datatable1.Sort = "sortExpression";
Sort data table

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

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

No comments:
Write comments
Recommended Posts × +