473,471 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

C# Web Service won't connect to database

Dear friends,
I'm a Web Services newbie and I have created a simple Web Service that given
3 parameters accesses a database and returns 1 value.
When run from Visual Studio 2005, the Webservice returns the correct
information from the database with no problems.
I have created a new Virtual Directory in my local IIS that points to the
VS2005 folder where the Web Service is.
When I run the Web Service from the browser like
http://localhost/wsfolder/webservice.asmx and then insert the 3 parameters,
after clicking INVOKE I always get the "Can't connect to database" that I
have created with a try/catch block for myConnection.Open();
I have my username and password for the SQL server in the code's connection
string.
Then I have created a simple c# Form application that consumes the Web
Service and get the same error of course.
What am I forgeting?
Thanks in advance,
Nelson

Feb 7 '07 #1
1 7161
Hi Nelson,

This sounds like it might be a user identity issue. When running in the IDE,
your database access is probably using your interactive user credentials.
However, when running from IIS, depending on your security settings on the
virtual directory, the aspx script may be running under the credentials of
the generic user which is used to serve anonymous requests. If this user
doesn't have access to the database, then you're going to have problems.

I'm not familiar with your environment of course, so this is just an
educated guess. But this would be the first thing I'd be looking at.

Hope this helps,

- Joseph Geretz -

"Nelson André" <Ne********@discussions.microsoft.comwrote in message
news:B5**********************************@microsof t.com...
Dear friends,
I'm a Web Services newbie and I have created a simple Web Service that
given
3 parameters accesses a database and returns 1 value.
When run from Visual Studio 2005, the Webservice returns the correct
information from the database with no problems.
I have created a new Virtual Directory in my local IIS that points to the
VS2005 folder where the Web Service is.
When I run the Web Service from the browser like
http://localhost/wsfolder/webservice.asmx and then insert the 3
parameters,
after clicking INVOKE I always get the "Can't connect to database" that I
have created with a try/catch block for myConnection.Open();
I have my username and password for the SQL server in the code's
connection
string.
Then I have created a simple c# Form application that consumes the Web
Service and get the same error of course.
What am I forgeting?
Thanks in advance,
Nelson

Feb 11 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: PF | last post by:
On one of our machines, all of the SQL Server 2000 components except for the main Server component (SQL Server core) itself were installed (Management tools, etc) a while ago and everything was...
10
by: amirmira | last post by:
I have a Windows Service developed in VB.NET that attempts to connect to a database as soon as the service starts. I have no problem when I start the service manually - but when I restart the...
3
by: adasilva | last post by:
I have create a Windows service that uses a timer to access a Web Service. The service is set to start Automatically and its using the local system account. The service also logs events to the...
8
by: Kevin D. | last post by:
Please note, I already posted this on the MySQL official forum, but received no response. I thought I'd try again in another location. My apologies to anyone reading this twice... Despite...
3
by: =?Utf-8?B?RGFuZGFuIFpoYW5n?= | last post by:
Now I have a web application, a web service and a SQL Server database. The Web application will invoke the web service, the web service invokes the SQL Server stored procedure. I let the web...
15
by: Joseph Geretz | last post by:
I'm a bit puzzled by the current recommendation not to send Datasets or Datatables between application tiers. http://support.microsoft.com/kb/306134 ...
5
by: mivey4 | last post by:
Hi, First off, I am aware that this is a very heavily documented error and I have done my homework for throughly researching probable causes before deciding to post my problem here. At this point,...
8
by: =?Utf-8?B?RGF2aWQrKw==?= | last post by:
Hi, I have been developing Web Services in VS2005. Usually I use the built in server in VS2005 to test and develop the Web Service. However I now want to make this Web Service available to...
9
by: Ryan Liu | last post by:
Hi, I use C# wrote an Client/Server application. In production environment, will be 130 clients (Windows XP) connect to a Server (Windows 2000/2003 Server) thought TCP/IP socket in a local 100M...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.