I am running a web service on my local machine (using standard VS.NET test
pages) that is attempting to access a SQL database on a network server. C#
code looks something like this:
[WebMethod]
public string GetSomething()
{
SqlConnection con = new SqlConnection();
con.ConnectionString =
ConfigurationSettings.AppSettings["connectstring"].ToString();
con.Open();
...
}
The problem is that the Open() statement always yields a "SQL Server does
not exist or access denied" message. The same code works fine when run from
a WinForms app, so I know that my connection string is good. Is this a
permissions issue or am I missing a setting somewhere?
Thanks in advance.
David
Keenan Newton - 17 Feb 2005 17:12 GMT
Can we see the conenction string as it looks inside the config file.
Also if you are using a trusted connection, it is quite possible the
ASP.Net web service does not have the proper rights to the sql server
D Godwin - 17 Feb 2005 18:08 GMT
Minus the actual values, it looks like this:
"Data Source=servername;User ID=u;Password=p;Initial Catalog=c;Persist
Security Info=True;"
Keenan Newton - 17 Feb 2005 21:17 GMT
Are you using the same config file in both circumstances?
D Godwin - 18 Feb 2005 18:31 GMT
As suspected, it was a permissions issue. Fixing it involved using
impersonation as described by MS at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/S
ecNetHT01.asp
jimskipper - 03 May 2005 16:04 GMT
I have the exact same problem with a VB.NET Web Service.
Identical code in a WinForms app succeeds, but the web service fail
with "SQL Server does
not exist or access denied." with the service on my local computer o
on our IIS server.
> *I am running a web service on my local machine (using standar
> VS.NET test
[quoted text clipped - 22 lines]
> Thanks in advance.
> David
-
jimskippe