c#


How to make the connection string visible throughout the solution (across layers)?


I have developed an Asp.net application using three tire architecture and i am reading the connetions string from web.conf file in the UI layer,
My problem is i have to pass the connection string as a parameter in all the functions that are in the Bo layer.
Is there any work around for making the connection string visible throughout the Bo layer so that i dont need to send the connetions string as parameter in all my method calls.
Include the System.Configuration reference to all projects in which you want to access the connection string and use the following code to access your connection string.
ConfigurationManager.ConnectionString["MyConnection"].ConnectionString
It is advisable to use a helper class to access your connection string.
internal sealed class Utility
{
public static string MyConnectionString{
get{
return ConfigurationManager.ConnectionString["MyConnection"].ConnectionString;
}
}
}
This will help you to move your connection string from web.config to any other location in future without breaking your code.

Related Links

Order by and Group in NHibernate QueryOver
Powershell output formatting
C# / XNA - 2D collision engine glitch?
Creating a GraphicsPath from a semi-transparent bitmap
Programming to interfaces - Facebook C# SDK
FTP upload in .net — not getting correct file path in some browsers
how to insert newline in string in c# after some particular digit?
Olson Time Zone Id to Windows Standard Format using Noda Time
Using Microsoft Interop to read and write into excel cell
Fql multiquery executing in graph explorer but not in c# .net
Calling a jQuery user defined function from Silverlight
how to deploy IE web control along with application
How to change HelpProvider's Font?
WCF timout that abort the current operation?
Missing reference reappeared?
How to convert excel files (xslx files) to pdf in the sharepoint web part?

Categories

HOME
airflow
spring-boot
drupal
classification
process
nagios
conceptual
nltk
atlassian-fisheye
sahi
pyodbc
runtime
oms
jcodemodel
suitecrm
distinct
derby
saucelabs
web-testing
loss
amazon-data-pipeline
keystone
xna
multipart
smali
android-wear-2.0
large-files
windows-10-mobile
pushpad
andengine
visual-studio-debugging
android-scrollview
mootools
incapsula
flex3
perf
kofax
ui-grid
vertical-alignment
uitextview
yank
monaca
standard-error
playframework-1.x
photoshop-script
r-commander
xamarin-test-cloud
opticalflow
multi-targeting
zedgraph
acceleo
lightspeed
msiexec
git-push
tinybox2
jigsaw
key-value-store
hotkeys
aws-kms
database-administration
custom-build-step
videoview
nonblocking
consul-template
eaaccessory
firewire
android-networking
system.diagnostics
veeam
conkeror
douglas-peucker
xmla
qxorm
frisby.js
tigase
pnunit
opencobol
flask-mongoengine
imaplib
nop
code-complete
dylan
servicemanager
gmail-imap
phone-state-listener
ntdll
states
erlide
diazo
yii-cactiverecord
recess
gmagick
jexcelapi
xcdatamodel
browser-state
versions
coderush-xpress
data-formats
file-icons
html-help-workshop
cross-cutting-concerns
hotfix

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App