Multiple mysql connection

2 posts, 0 answers
  1. Zbigniew Kozłowski
    Zbigniew Kozłowski avatar
    60 posts
    Member since:
    Apr 2010

    Posted 01 Sep 2010 Link to this post

    Hi,
    have can i switch mysql connect on start? i mean i got 1 mysql database but two seperate IP's i need to switch between those two IP's ofc i know how to detect which IP to use, but dont know how to swtich IP in ORM connection.
    i've found http://www.telerik.com/community/forums/orm/general-discussions/support-multiple-databases.aspx but its with mssql and mysql, and also its for two seperate databases and i need it for 1 database but two IP ;)
  2. Serge
    Admin
    Serge avatar
    375 posts

    Posted 03 Sep 2010 Link to this post

    Hello Zbigniew Kozłowski,

     What you need to do is just create two different connections for the different IP's. If you are using the new domain model approach the context constructor accepts a connection name so it would be as easy as adding a second connection string to the app.config of the executing project.

    If you are using the classic wizards approach you have to add the new connection in the app.config. Then use code that looks like this to get an appropriate object scope:

    IObjectScope scope1 = Database.Get("DatabaseConnection1").GetObjectScope();
    IObjectScope scope2 = Database.Get("DatabaseConnection2").GetObjectScope();

    I do hope this helps. Please do not hesitate to contact us back if you face further trouble or have any questions.

    Best wishes,
    Serge
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top