simple way to change the connection at run time??

Thread is closed for posting
4 posts, 0 answers
  1. Carlos G Ortiz
    Carlos G Ortiz avatar
    1 posts
    Member since:
    Aug 2009

    Posted 04 Oct 2009 Link to this post

    there any property to change the connection string???
    From what I see in your documentation sought more complicated and inefficient way of doing this.
    Besides the fact that I failed to change the connection to a server in production
     Everything is fine if you play with a fixed connection
    but in the real world in products ranging to final consumers
    normally do not have the slightest idea of the server name.
    in most cases neither the name of the BD,user or password only tables index keys  are generated by scripts ..

    It is illogical to think that these data are not changed by parameters within the program, you can not compile one application for each customer of  the same product.

     30 days ago about, the ORM was acquired at the suggestion of a programmer
    do some consulting all fine until I asked him to connect to another server with another user etc.
       perhaps neither he nor I understand the product , and I guess not understand 
    until we can dynamically connect to the server we choose by parameters.
    20 days and are trying to do this that would linqtosql matter of 30 seconds really do not understand.
    Any help will be appreciated
    best regards

  2. PetarP
    PetarP avatar
    754 posts

    Posted 07 Oct 2009 Link to this post

    Hello Carlos G Ortiz,

    You can replace the connection string that is loaded from the app.config file during runtime with some custom XML of yours. Here is an example:
    string myDatabase = "Northwind"
    string serverName = "(LOCAL)\SQLEXPRESS"
    string myuser = "user"
    string mypassword = "pass"
    const string myconfig =  
                    "<reference assemblyname='ClassLibrary1' />"
                    "<connection id='DatabaseConnection1'>"
                    "<backendconfiguration id='mssqlConfiguration' backend='mssql'>"
                "<mappings current='mssqlMapping'>"
                    "<mapping id='mssqlMapping' />"
    XmlDocument xmlDoc = new XmlDocument(); 
    Database db = Database.Get("DatabaseConnection1", xmlDoc.DocumentElement); 
    Additional information can be found here.

    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.
  3. Mark Reynolds
    Mark Reynolds avatar
    2 posts
    Member since:
    May 2010

    Posted 06 Sep 2013 Link to this post

    The additional information link is a dead link.
  4. Doroteya
    Doroteya avatar
    498 posts

    Posted 09 Sep 2013 Link to this post

    Hello Mark,

    Excuse us for the inconvenience caused.

    Generally, the article you are looking for was deprecated.

    Perhaps you could share a little bit more information about the scenario you need to implement and the setup on your machine and we could suggest to you relevant resources.

    Additionally, here is the latest OpenAccess ORM documentation.

    I am looking forward to your feedback.

    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
Back to Top