Home > DeveloperSection > Blogs > Globalized Connection String

Globalized Connection String

ASP.Net ASP.Net 
3 Comment(s)
 2701  View(s)
Rate this:

Globalized connection string meant for that if you are designing a vast application that having so many windows forms and you need to control all the application using an app.config file.


Globalized connection string

By Awadhendra Tiwari on   6 years ago

Can you please give me a example on Globalized connection string.


Example of Globalised Connection String

By fuan Edgar on   6 years ago
create an app.config file (Add----> New Item-----> Application configuration file)

you will get this:

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

    <add key="GlobalConnectionName" value="Data Source = serverAddress;Initial Catalog = DBName;User Id=xyz;    Password=xxxx;"/>

Now where you want to use this GlobalConnection :
Add "System.Configuration" Namespace

create your connection object:
SqlConnection con=new SqlConnection();

 con.ConnectionString = ConfigurationSettings.AppSettings["GlobalConnectionName"];

& you are done......

Don't want to miss updates? Please click the below button!

Follow MindStick