Database connection strings from a database

Thread is closed for posting
4 posts, 0 answers
  1. Alessandro Federici
    Alessandro Federici avatar
    6 posts
    Member since:
    Nov 2009

    Posted 30 Nov 2009 Link to this post

      I just started the evaluation of OA and I like what I see so far very much. I have one big problem and I couldn't find any post or article that clearly helped me resolving this issue. I am writing a system that connects to many databases (75+). These databases have different schemas (20 have schema A, 10 schema B, etc) and for each I will generate a DAL library using OA. So, all good so far. The problem is that the connection information for those databases is... in a database (the main dbof our product) which lists things like this:

    Id (string)
    Name (string)
    ConnectionString (string)
    DALLibrary (string)

    What I need is, essentially, change the connection string of a OA library and make it point to the instance I am interested in.
    Storing this kind of information in Config files is absoutely NOT an option (for obvious security reasons and other design reasons) but all I saw, so far, seems to point to the fact OA needs that info in config files. I've seen the overloads that allow you to pass an XElement but I found no examples of how to use that (and that seems the workaround to my problem).

    Can anybody help?

    Thanks a lot!

    Alessandro Federici

  2. IT-Als
    IT-Als avatar
    381 posts
    Member since:
    Sep 2008

    Posted 01 Dec 2009 Link to this post

    Hi Alessandro,

    One way I could think of was to extend the object scope provider (gets generated for you by OA Wizard when you enabled a project) to support multiple Database objects (that is the Telerik defined Database class).

    Because if you look at this in the documentation it can take an XML configuration like the one below:

         <connection id="ArchiveConnection"

    Now, the trick is to transform the information in your database to something like the above, eventually including also the references section at runtime...

    Like a method (still based on the original ObjectScopeProvider.cs) called.... GetNewObjectScope(string datasourceId), where datasource Id is the one you have in your table.

    Within the GetNewObjectScope(string) method, you query your database for the connection string, dynamically create a xml snippet and pass it to the Database.Get(...) method as parameter.... Once you have the Database instance you can store it within a Dictionary<string, Database> type for further references.. and then you use the instance to do a databaseInstance.GetObjectScope() like normally in the ObjectScopeProvider.

    Hope you get the idea. The link to the doc also has an example config, which should get you started.



  3. Alessandro Federici
    Alessandro Federici avatar
    6 posts
    Member since:
    Nov 2009

    Posted 01 Dec 2009 Link to this post

    Thank you. I'll look into it
  4. Alexander
    Alexander avatar
    727 posts

    Posted 01 Dec 2009 Link to this post

    Hello Alessandro Federici,

    I would like to add that you should be able to use the new connection settings that work with standard .NET connection strings (introduced in the 2009 Q3 version). With a connection string the connection node would look like this:
       <connection id="DatabaseConnection1">
          <connectionString>Data Source=(local)\sqlexpress;Initial Catalog=Northwind;Integrated Security=True</connectionString>
    The rest of the configuration is the same.

    All the best,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top