Hi,
I have an Web Service project, and for the purposes of testing I have a web method that simply connects to the Database (SQLExpress on my local machine using SQL authentication), and returns a dataset. I am storing the connection string in the web.config file. I have another project which consumes the web service, and when I step through this one and enter the web method, the connection string is null so it fails to return anything.
The code in the web.config looks like:
The code Im using in the web method to access this looks like:
As I say - when I Debug the Web Service on its own it works fine, but when run from a browser on its own (http://localhost/MyProject/MyWebService.asmx) it does not return anything, and when Ive debugged it from another project that consumes it this is because the connection string is null.
Any thoughts?
I have an Web Service project, and for the purposes of testing I have a web method that simply connects to the Database (SQLExpress on my local machine using SQL authentication), and returns a dataset. I am storing the connection string in the web.config file. I have another project which consumes the web service, and when I step through this one and enter the web method, the connection string is null so it fails to return anything.
The code in the web.config looks like:
Code:
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings>
<add name="ConString"
connectionString="Data Source=PC\SQLEXPRESS; User Id=user; Pwd=password; Initial Catalog=db; Min Pool Size=5; Max Pool Size=75; Pooling=True"/>
</connectionStrings>
Code:
System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/MyWebSiteRoot");
System.Configuration.ConnectionStringSettings connString;
connString = rootWebConfig.ConnectionStrings.ConnectionStrings["ConString"];
Any thoughts?