PatrickIRL
Programmer
- Jun 25, 2003
- 383
Hi, Starting my first web app using ASP.NET and I'm storing the connection string in the web.config:
Problem is when I assign the value stored in "foo" to a string:
and then attempt to open a connection using that I get an error: Can't find server or no permissions: Invalid string
BUT if I use the same connectionstring without using the ConfigurationManager it works fine!
This works and connects to the database and displays the correct data:
Any ideas???
Thanks in advance, Patrick
Code:
<connectionstrings>
<add name="foo" connectionstring="provider=SQLOLEDB.1;Data source=<source>;Initial Catalog=<database>;UID=<user>;PWD=<pwd>";
</connectionstrings>
Problem is when I assign the value stored in "foo" to a string:
Code:
string strCN=ConfigurationManager.ConnectionStrings["foo"].ConnectionString;
and then attempt to open a connection using that I get an error: Can't find server or no permissions: Invalid string
BUT if I use the same connectionstring without using the ConfigurationManager it works fine!
This works and connects to the database and displays the correct data:
Code:
cn.connectionstring="provider=SQLOLEDB.1;Data source=<source>;Initial Catalog=<database>;UID=<user>;PWD=<pwd>";
Any ideas???
Thanks in advance, Patrick