Single Datasource, multiple databases

4 posts, 0 answers
  1. Jeremy
    Jeremy avatar
    4 posts
    Member since:
    Jan 2019

    Posted 26 Mar 2019 Link to this post

    I am trying to write an inventory report, which is using two databases.

    The primary site uses the database InvA, and where the product is in the secondary facility this database has a secondary code which is basically the key for the inventory line in the InvB database.

    I have written a SQL statement that connects to the two databases and collects the data they want, combining where needed and the data matches what they want.  A single table combining the product quantity by product code and lot code, regardless of facility.


    1) The problem I'm having is how do I create a report that uses my SQL statement which connects to two databases?  Is there a way of assigning two connection strings to a single SqlDataSource?  Is there an example for this?

    2) Do I have to programmatically "merge" my datasources into a single data table, and then use an ObjectDataSource?  Is there an example of this?

    3) Does Telerik use DataSource and Database interchangeably, meaning I can only use one database per report?  Should I be asking the client if I can modify the database to include a table valued function?

  2. Jeremy
    Jeremy avatar
    4 posts
    Member since:
    Jan 2019

    Posted 28 Mar 2019 in reply to Jeremy Link to this post

    I am going to go with number 2 on my post above.

    Is there any plan for multiple databases per sql data source?  

    The road map only shows up to May 2019 and there is nothing like what I was looking for.

  3. Silviya
    Silviya avatar
    421 posts

    Posted 29 Mar 2019 Link to this post

    Hello Jeremy,

    Let me answer your questions as follows:

    1. Only one connectionString is allowed per SQLDataSource. If you prefer to get data from two databases:
    - You can use two separate SqlDataSource components. Each component can be used as a DataSource for a data item (e.g. Report, SubReport, Table, Crosstab, List, etc.)
    - You can create a SQL query joining records from different databases.

    2. If you use custom data access layer and a data model, you can use the ObjectDataSource and expressions to get data from collection properties without additional data source components - How to Databind to Collection Properties.

    3. Every Data Item can be bound to a single Data Source Component. Thus if you need to use more than one data source components, you should use another data item in the main one (usually report). For example, you can use SubReport or Table item inside the main report, which would be bound to your second database.

    Best Regards,
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  4. Tran Mai Loa
    Tran Mai Loa avatar
    1 posts
    Member since:
    Jun 2018

    Posted 08 Apr in reply to Silviya Link to this post

    Hi Silviya,

    "You can use two separate SqlDataSource components." Could you give me the code sample with sql server?

    Many thanks!

Back to Top