472,127 Members | 1,836 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

Accessing Connection String from appSettings

Hi,

Can anyone help me for how to access connection string defines in
App.config file in an Windows form application.
I`m doing project in C#.NET and SQL Server2000.
So you are also pleased to give me suggestions on the above mentioned
platforms.

Thanks.

Jan 23 '06 #1
3 25930
Hello Vijayata,

Yo have to set a reference to System.Configuration and then use the ConfigurationManager
class.

--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net
http://www.cornerstone.se
Hi,

Can anyone help me for how to access connection string defines in
App.config file in an Windows form application.
I`m doing project in C#.NET and SQL Server2000.
So you are also pleased to give me suggestions on the above mentioned
platforms.
Thanks.

Jan 23 '06 #2
Am 23 Jan 2006 02:09:35 -0800 schrieb Vijayata:
Hi,

Can anyone help me for how to access connection string defines in
App.config file in an Windows form application.
I`m doing project in C#.NET and SQL Server2000.
So you are also pleased to give me suggestions on the above mentioned
platforms.

Thanks.


Hi,

to read the connection string out of your app.config file in your
application try something like this (e.g. for Oracle):

String myConnection =
ConfigurationSettings.AppSettings["connectStringORA"];
myConn = new OracleConnection(myConnection);

Your app.config file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="connectStringORA" value="Data Source=xxx;" />
</appSettings>
</configuration>

To learn more about connection strings, this page is quite interesting:

http://www.connectionstrings.com/

Bye

Horst
Jan 23 '06 #3
Hello Patrik,

System.Configuration.dll that is .. The ConfigurationManager class is in
the System.Configuration namespace.

string connectionString = ConfigurationManager.ConnectionStrings["importDb"].ConnectionString;
--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net
http://www.cornerstone.se
Hello Vijayata,

Yo have to set a reference to System.Configuration and then use the
ConfigurationManager class.

--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net
http://www.cornerstone.se
Hi,

Can anyone help me for how to access connection string defines in
App.config file in an Windows form application.
I`m doing project in C#.NET and SQL Server2000.
So you are also pleased to give me suggestions on the above mentioned
platforms.
Thanks.

Jan 23 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Fernando Lopes | last post: by
4 posts views Thread by Andrew | last post: by
7 posts views Thread by John A Grandy | last post: by
2 posts views Thread by Jon Paal | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.