Can't see Connection Strings in wwwroot web.config

D

Dave

We store all of our connection strings in the root web.config. I have a
connection string called connectionString1 stored in the web.config
file at wwwroot. I can get to this through code no problem. My problem
is when I use the Grid View control and configure the datasource. The
wizard asks for a datasource type I select sqlserver. Then it asks for
a connection string, I click on the drop down. No connection string. If
I move my connection string into the local web.config it shows up. What
am I missing? Any suggestions welcome Thanks
 
G

Guest

Dave,
Your missing the modern enterprise environment does not allow every web_app
access to the same connections.

Good Luck
DWS
 
D

Dave

Are you saying that the best practices of 1.1 are now not supported in
2.0? We create a different connection string for every app but we store
them all in the root web.config. This is very beneficial, because it
allows us to secure the web.config to just a few people while allowing
many developers to write apps. It is also good for our migration path.
I can develop an app on my local machine using a test database, then
when the app is ready to move to production I can simply move the
source code to the production web server and the connection to the
database is changed to the production database. If the modern
enterprise environment does not support this then I think perhaps we
should re thing the new stuff :)
 
J

Juan T. Llibre

re:
I move my connection string into the local web.config it shows up.
What am I missing? Any suggestions welcome Thanks

What you're missing is that VS reads web.configs on a per-application basis.

As long as your connection string is within the same app, VS will see it fine.
If you're in a different app, though, VS won't see it.
 
D

Dave

Juan,
Thanks for answering but I think you misunderstood me. When I say the
root Web.config I meet the root of the website. In 1.1 I was able to
use the website config to hold the connection strings in appsetting in
the web.config file at the root of the website. Then I would create a
sub folder for each application and configure it, but I was still able
to appsettings from the config file at the higher level. this is not
possible with connection string. The other problem I have run into is
that if I add a connectionStrings tag to me root config file all my 1.1
programs stop working because they do not recognize the tag. Is it now
considered best practice to store my connection strings in the
web.config of each application instead of at the root or machine level.
I find this strange since I first learned about this method at a MSDN
event for Widby.
 

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,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top