Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connection string in cls 1

Status
Not open for further replies.

tek1ket

MIS
Jan 25, 2009
70
IR
I am newbie in C#. i am programming a project with several Form. what is the best way to define sqlconnection string in a way that if i want to change it , i wouldn't change it in every form.
should create class and define the connection string in it and then get it every time i need it. in that case i change it in the one cls file if i have to change it?
what is the best way?

and one more question is it better to program the openning connection string and the rest or using the ready to use sqlconnection component in .NET?

thank you
 
place the connection string in the app.config's connectionstrings node. then use the configurationmanager.connectionstrings array to access the specific connection string.

data access is a solved problem and you should not need to access the ado.net components directly. using active record, nhibernate or LLBL the database to domain mapping is done.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
i am programming C# for windows application so there isn't a app.config's

and also do u have any good source in active record in internet?

thank you
 
just add an app.config file to your project and set the connections string node.

for information on active record (and nhibernate) google "castle active record". Castle Project is responsible for maintaining the project. there is a google group for help and the source is available from sourceforge.net the binaries on castle's website are outdated. they work, but alot of advances and new features have been added since the initial release.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top