c# - Sql connection string for data access layer -


i using direct connection string is

string constring = "data source=.\\sqlexpress; initial catalog=mydb; integrated security=sspi";

i need connection string stored in web.config file like:

<connectionstrings> <add name="sqlcon" connectionstring="data source=.\\sqlexpress; initial catalog=mydb; integrated security=sspi" providername="system.data.sqlclient" /> </connectionstrings> 

the problem is not accessible in data access layer. working on 3 layer architecture model. won't adding references data access layer, such system.web etc. every day class libraries more , more classes. realize time use globally accessible connection string when submit project connection string need changed @ 1 place on university computer.

you won't have add reference web dlls in data access layer.

it depends on structure, if dlls copied web sites's bin folder thorough project references - web config connection string used directly web site's web config. connection resolved @ runtime in host web site hosted web server. no need add 1 data access dll itself. means single process architecture - connection string globally available.

if data access layer hosted on app server, might have web config web service exposing business/data layer. common pattern expose business layer w/data access using wcf service. service have it's own web.config file - separate web.config defined web site. key point though wfc service needs connection string. web site's web config typically contain information how invoke service (wcf configuration).


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -