This is a migrated thread and some comments may be shown as answers.

data acces domain model - connection string

3 Answers 36 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
MSu
Top achievements
Rank 2
MSu asked on 04 May 2016, 08:38 AM
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

3 Answers, 1 is accepted

Sort by
0
Doroteya
Telerik team
answered on 09 May 2016, 06:46 AM
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.
0
MSu
Top achievements
Rank 2
answered on 23 May 2016, 11:15 AM

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? 

0
Accepted
Boyan
Telerik team
answered on 26 May 2016, 09:02 AM
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.
Tags
Data Access Free Edition
Asked by
MSu
Top achievements
Rank 2
Answers by
Doroteya
Telerik team
MSu
Top achievements
Rank 2
Boyan
Telerik team
Share this question
or