Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Web.Config - Not working??

Status
Not open for further replies.

Paladine

Technical User
Sep 16, 2001
26
CA
Hi folks, I have set the appSettings Tag in the web.config file to hold my database connection string.

Like so:
______________
<appSettings>
<add key="strConn" value="Provider = Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\ ID=Admin;Password=;" />
</appSettings>
<system.web>

_______________

But when I try to use the following line in the code behind I get the following error message:

code:
_________

OleDbConnection MyConn = new OleDbConnection(ConfigurationSettings.AppSettings("strConn"));

__________

Error Message:
______________

'System.Configuration.ConfigurationSettings.AppSettings' denotes a 'property' where a 'method' was expected

______________

Now I have used the same method in VB.Net and it works fine, but this error message has be completely stumped.

I appreciate any assistance with this.

Thanks


_________________
Paladine
 
If you're using c#, the indexer (I think they're called that anyways...;)) for objects is defined by [], not ().

You'll want to be using ConfigurationSettings.AppSettings["strConn"];

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Thanks AtomicChip!

_________________
Paladine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top