error vsto application can't access connection string in app.confi

J

Jayasriraghu

I am programming in vsto 2003. when i moved my connection string to
app.config, I get error "the connection string property not initialized".
the following code works. I am new to programming. can anybody help?.Thank you
protected void makeConnection()
{
cn = new OleDbConnection();
cn.ConnectionString="Provider=SQLOLEDB.1;user id=sa;password =####;data
source=#####;initial catalog=BPT_TEST";
cn.Open();
}

But the following code doesnot

protected void makeConnection()
{
cn = new OleDbConnection();
cn.ConnectionString =
System.Configuration.ConfigurationSettings.AppSettings["SqlconnString"];

cn.Open();
}

<configuration>
<appSettings>
<add key="SqlconnString" value="Provider=SQLOLEDB.1;user id=sa;password
=#####;data source=######;initial catalog=BPT_TEST" />

</appSettings>
</configuration>
 

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

Top