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

How to change the label color of an IntField - Unity
how to put row number for report rdlc matrix
Why do I get a build error in a WPF UserControl and its owner Window only at design time?
How to convert dd/MM/yyyy string to MM-dd-YYYY DateTime int C#
Extract certificate name with regex in c#
Quick Info Not Displaying Possible Exceptions for Some Projects
Using JSON Patch to add values to a dictionary
Replace “\” with “\/” in C#
RabbiMQ C# driver Causes System.AccessViolationException
How to prevent .net compiler to strip out classes which are considered as unused?
How improve performance Entity Framework 6
Security implications of displaying files from user-provided paths
Initialization with null-coalescing operator?
Which c# class should be used when parsing XML from a remote URI?
How to remove text from a specific line in file without creating unwanted space using c#?
C# adding +5 to a datatable if criteria is met

Categories

HOME
youtube-api
url
stanford-nlp
leaflet
ssh
ldap
glsl
lithium
sdk
atlassian-fisheye
markdown
browserstack
revit-api
soap-client
rename
google-search-appliance
aspectj
repeater
web-testing
luis
dompdf
versioning
internet-explorer-7
filehelpers
beacon
aws-devicefarm
gpo
xforms
aws-certificate-manager
deployment-descriptor
smart-device
typeorm
sphinx4
blockly
spring-oauth2
directions
eclipse-jdt
minitest
ragel
scip
redhat-brms
queryover
ninja-forms
tapply
android-graphview
jvisualvm
intervention
npoco
spring-webflow-2
jks
jenkins-2
automapper-4
runner
react.rb
fckeditor
r-commander
jtextarea
critical-section
catalyst
alarmmanager
android-tabs
easy68k
settext
foreground
init
key-value-store
kik
transaction-isolation
razorengine
dcast
overlapping
gitk
page-flipping
teamwork
genome
valdr-bean-validation
sicstus-prolog
google-experiments
sony-xperia
touch-typing
alpha-beta-pruning
quickfixn
jsonschema2pojo
famous-engine
tigase
pnunit
selenium-grid2
ios-enterprise
dotcmis
git-subtree
autofilter
mahara
jfilechooser
mencoder
grape-api
azure-pack
mmo
biztalk-deployment
ntdll
esi
derived-class
hypertable
xcode4.6.3
maven-eclipse-plugin
utm
openwrap
opendir
overlays
youtube.net-api
zipstream
html5-animation
dongle
carbon-emacs
konsole
dgml
file-icons
tracd

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