q; connection string

G

Guest

Hello,

this code does not return connection string
string connStr =
ConfigurationManager.AppSettings["myDBConnectionString"];

app.config
<connectionStrings>
<add name="PVS.Properties.Settings.myDBConnectionString"
connectionString="Data Source=MyServer;Initial Catalog=myDB;User
ID=myUser;Password=myPassword"
providerName="System.Data.SqlClient" />
</connectionStrings>

What is wrong?
 
W

Will Asrari

using System.Data.OleDb;

OleDbConnection cn = new
OleDbConnection(ConfigurationManager.AppSettings["myDBConnectionString"]);
 
K

Kevin Spencer

Your Connection String is not in the AppSettings section of your app.config
file.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

The man who questions opinions is wise.
The man who quarrels with facts is a fool.
 
M

MSDN

<appSettings>

<add name="myDBConnectionString" value="Data Source=MyServer;Initial
Catalog=myDB;User ID=myUser;Password=myPassword" />

</appSettings>

string connStr = ConfigurationManager.AppSettings["myDBConnectionString"];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top