ADO.NET connection string in windows application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was wondering how you can place a connection string to a database in a
windows application in one place so that it can be referenced easily from
anyplace in the code where a database connection is needed. I want to be
able to access the string value after it has been deployed so I can change
the string to point to any database. Should I use some sort of include file?
Or something else? I know in ASP.NET you can use an application variable.
But what do you use for a Windows application?
 
=?Utf-8?B?TGxveWQgUw==?= said:
I was wondering how you can place a connection string to a database in
a windows application in one place so that it can be referenced easily
from anyplace in the code where a database connection is needed. I

You can declare a static on a an object.
want to be able to access the string value after it has been deployed
so I can change the string to point to any database. Should I use
some sort of include file? Or something else? I know in ASP.NET you
can use an application variable. But what do you use for a Windows
application?

You should use the app.config, or something like this:
http://www.codeproject.com/dotnet/XMLSettingsFile.asp




--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
 
Back
Top