Getting Connection String from Web.Config in ASP.NET Express

M

Mark

I'm trying to get the frickin string out of the frickin config file
(using VB), but foundation classes don't seem to match the
documentation. Either I have this 30 line example where I walk a
collection fished out from nine levels down or I have a C# example
(Programming ASP.NET 2.0, Core Reference):

connstr =
ConfigurationManager.ConnectionStrings["NWind"].ConnectionString;

Which is nice but flat out doesn't match reality (but I sure wish it
did).

So how do you guys cope with this? PS: I'm trying to store the
connection in the application (Global.aspx) so I can reuse it. That's
how I used to do it in the old ASP days. Is that how it's still done?
 
C

Christopher Reed

If you're using VB, change the brackets to parentheses. Otherwise, this is
how I get the ConnectionString out of the config file.

As for putting stuff in the GLOBAL.ASAX file, don't do it.
 

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,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top