c# - Get connectionstring from Registry LINQtoSQL -


i confused how connectionstring stored in registry used datacontext.

where , how go this:

public dataclassesdatacontext() :              base(global::ddstime.properties.settings.default.ddstimeconnectionstring, mappingsource)     {         oncreated();     } 

to not using properties.settings.default.ddstimeconnectionstring value registry?

i want way, because application used @ different locations, , not want leave connectionstring in config file see. little script, machines insert connectionstring key in registry, , there no need create different 'versions' each locations uses own sql server onsite.

if don't have suitable constructor, should easy create 1 :

public dataclassesdatacontext(string connectionstring) :          base(connectionstring, mappingsource) {     oncreated(); } 

this means need pass connectionstring every time create new datacontext. if prefer, can change current constructor like

private static string getdefaultconnectionstring() {     var connectionstring = ... // read value registry     if (string.isnullorempty(connectionstring))         connectionstring = global::ddstime.properties.settings.default.ddstimeconnectionstring ;     return connectionstring; }  public dataclassesdatacontext() :             base(getdefaultconnectionstring(), mappingsource) {     oncreated(); } 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -