Specifying connection string at run-time

Thread is closed for posting
2 posts, 0 answers
  1. Dan
    Dan avatar
    35 posts
    Member since:
    Oct 2008

    Posted 06 Nov 2009 Link to this post

    I am trying to determine the best way to specify what OpenAccess connection to use at runtime.  I found 2 different articles Todd Anglin regarding this.

    1) http://blogs.telerik.com/blogs/posts/09-01-06/Understanding_Where_to_Set_Connection_Strings_in_OpenAccess.aspx
    2) http://blogs.telerik.com/toddanglin/posts/09-01-09/improving_openaccess_objectscopeprovider_for_runtime_connection_config.aspx

    In the first article, Todd specifies to use the Telerik.OpenAccess.Database.Get() method to specify a string for the connection name.  I assume after that, you call GetObjectScope on the resulting Database object to get the IObjectScope for execution.  This seems to work for me, but it makes me wonder why article 2 exists and what the generated ObjectScopeProvider1.cs file is really for.  The AdjustForDynamicLoad() method seems to be the only useful method in the generated ObjectScopeProvider1 class and I'm not completely sure what that does, but Todd doesn't modify that in the second article.  Under what circumstances is it necessary to use something other than Database.Get(...).GetObjectScope()?

    Thanks in advance,

    Lars Solberg

  2. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 06 Nov 2009 Link to this post

    Hello Lars Solberg,

    the ObjectScopeProvider classes are generated by enable project wizard so that our databinding implementations can obtain a Database or ObjectScope. It is perfectly possible to life without an
    ObjectScopeProvider! I do that all the time .... :-)
    Also, this helper class allows us to obtain the assembly that is trying to open the Database. And in cases, where an entry assembly is not available, the AdjustForDynamicLoad method is needed in order to find the right entries into the configuration.
    You can have more than one ObjectScopeProvider too...

    Regards,
    Thomas
    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