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

c++ - CPP, 'X' button listener -

shared memory - gstreamer shmsrc and shmsink with h264 data -

r - Add string of (variable number of) arguments to a function within a function -