data acces domain model - connection string

4 posts, 1 answers
  1. Marco
    Marco avatar
    11 posts
    Member since:
    Jan 2014

    Posted 04 May Link to this post

    Hello

    In my case I have a project with a data acces domain model.
    How can i save the connection string content in a user property?
    When I use the wizard, I can't choose a property value.

    Please see the attachement.

    Regards, Marco
  2. Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 09 May Link to this post

    Hi Marco,

    Thank you for contacting us.

    In general, when you use the wizards, the connection string you see on the Setup Database Connection page is preserved in the App.config\Web.Config file of your project. Data Access resolves it from there. In the specific situation, I wasn't able to completely understand the situation on your side. Could you provide me with more details about the scenario on your side? Would you like to resolve the connection string through your code or you would like to place it in a specific location?


    Regards,
    Doroteya
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  3. DevCraft banner
  4. Marco
    Marco avatar
    11 posts
    Member since:
    Jan 2014

    Posted 23 May in reply to Doroteya Link to this post

    Hello

    In my application, I can connect many different databases with the same structure. Now the question is, what's the best way to change the connection at runtime. My first idea was, to save the connection string in Setting.Properties.Default.ConnProp. When I change the database i write the new connection in Setting.Properties.Default.ConnProp. My second idea was to use the entitiesModel constructor to change the database connection (new EntitiesModelIECProject(connectionString)). Can u explain me, which is the better way? 

  5. Answer
    Boyan
    Admin
    Boyan avatar
    100 posts

    Posted 26 May Link to this post

    Hi Marco,

    Yes, you are right, Telerik Data Access has a context constructor that allows you to provide a connection string. In order to switch the connection string during runtime, once you have resolve the connection string, being from a settings files or somewhere else, you can pass it to a Telerik Data Access context. Please refer to this documentation article for further information on how to initialize Telerik Data Access manually.

    Alternatively, if your connection strings are known in advance, you can store them as separate connection string entries in the connection string section of the web.config/app.config of you application and let Telerik Data Access resolve them for you. In order to achieve that, you can use the same constructor, but instead of passing a connection string - pass the name of the connection string as specified in the web.config/app.config. This will instruct Telerik Data Access to read and use the connection string matching the passed name.

    Additionally, are you targeting the same database server always? If not, you may be interesting in this documentation article which describes how to achieve support for multiple backends.

    I hope this is helpful. Do get back to us with any further questions.

    Regards,
    Boyan
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Back to Top