Last post Sep 18, 2017 05:34 AM by Rebeca Loomz
Sep 15, 2017 12:11 AM|coreysan|LINK
What I'd like to do is create a report that will pull data from 6 databases, where the schema is the same for all 6,
and consolidate the data into the one report.
But how can I do this without being prompted? Would I write the query to use a variable and incorporate a loop?
For example, would this work (this is pseudo code):
for each db in "db1, db2, db3, db4, db5, db6"
SELECT * FROM @db.dbo.mytable
Or is there a better way to do this?
Sep 15, 2017 02:39 AM|Deepak Panchal|LINK
you can try to store connection string with in array.
if your all database have same numbers of table and fields then you can just try to loop through the array.
fetch the connection string one by one and pass that connection string to fetch the data from particular database.
then further you can process the data as per your requirement and outside the loop you can assign all fetched data to the report.
so if you use this approach , you can store the connection string in Web.config.
Sep 18, 2017 05:34 AM|Rebeca Loomz|LINK
Hey Coreysan, I guess you have come to know now how to Parametized (expression) Connection String without being prompted. I would just add a little suggestion here for you to read out the complete guide on Connection String written by Andy Miller who is
a well-known ASP.Net Developer and have answers for all queries for sure.