General Discussion Board - Please post questions, answers, (polite) opinions, and use-cases. Moderators reserve the right to amend the text/subject line or re-categorise the post to better suit the forum configuration if necessary.
Change db connection string at runtime/dynamically
04/12/2017
|
migrator Administrator Posts: 63
|
What is the best way to set the connection string at run time, so the generated data and business objects point to a database specified by code. I need to use this in application where I can't specify the database in a app.config file, since it won't be accessible at runtime
|
|
0
link
|
04/12/2017
|
migrator Administrator Posts: 63
|
Hi, there are some public properties that were created specifically for this purpose, i.e. changing the connectionstring at runtime. Usage: At an appropriate place in the code, you can override the connection string by setting it statically:
DATACONN0_TxConnectionProvider.ConnectionString = "Server=xxx;Port=xx;Initial Catalog=etc etc"; DATACONN0_BaseData.StaticConnectionString = "Server=xxx;Port=xx;Initial Catalog=etc etc";
both overrides would be necessary, one is just for queries (non-transactional) and the other provides transactional support.
|
|
0
link
|