locked
How to Use Parametized (expression) Connection String without being prompted RRS feed

  • Question

  • User248267340 posted

    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

    end

    Or is there a better way to do this?

    Friday, September 15, 2017 12:11 AM

Answers

  • User347430248 posted

    Hi coreysan,

    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.

    Regards

    Deepak

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 15, 2017 2:39 AM

All replies

  • User347430248 posted

    Hi coreysan,

    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.

    Regards

    Deepak

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 15, 2017 2:39 AM
  • User2020505780 posted

    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. https://www.reecoupons.com/categories/halloween

    Monday, September 18, 2017 5:34 AM