Click here for Vacation Photos

DBconn config file

An application configuration file follows a specific XML schema. The appSettings section is a predefined section of the configuration file designed to make it very easy to retrieve a value based on a given name. This is the easiest way to add application-specific settings into an application configuration file. The appSettings section of the configuration file consists of a series of “add” elements with “key” and “value” attributes. While the appSettings section is predefined, it is not included in a configuration file by default and must be manually added.

A simple example of a configuration file would be the following:

< ?xml version="1.0" encoding="utf-8" ?>

The AppSettings property of the ConfigurationSettings object in the System.Configuration namespace is used to get the settings.

For example, to read either of the settings above,
the following sample code would do the trick:

// Read appSettings string title = ConfigurationSettings.AppSettings[”ApplicationTitle”];

string connectString = ConfigurationSettings.AppSettings[”ConnectionString”];

Now, you could easily set a dynamic title value or read database connection string information from the application configuration file. This gives you the freedom to adjust settings without having to recompile any code. then just pass it into say a SQL connection like so :

SQLConnection cnn = new SQLConnection ( connectString );
// there ya go !



Digg it | Save to del.icio.us | Netscape | Reddit | Stumble It!

- - - - - S P O N S O R I N G     A D V E R T I S M E N T - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Post your thoughts in the Comments ...
Not signed up to share your ideas & thoughts?

It’s free and easy to collaborate!
Click Here to begin

Click Here to earn money for reviewing this post

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Leave a Reply

You must be logged in to post a comment.