SQLConnection.Open() in a WebService

S

Stephen

I'm experiencing a strange problem that has me baffled. I created a
webservice with a webmethod that connects to a remote MS SQL Server:

SqlConnection mySQLConnection = new SqlConnection();
mySQLConnection.ConnectionString="data source=192.168.30.44;
uid=rocky;pwd=raccoon;database=myDatabase";
mySQLConnection.Open();

This code works fine in the Windows app with either SQL Server 7 or
2000. It also works fine in the webservice app with one server, which
happens to be SQL Server 7. It does not work with the other server,
running SQL Server 2000. It generates the error "server does not
exist or access is denied" at mySQLConnection.Open().

I can connect to either database using Enterprise Manager.

Can anybody help?

TIA!
 
D

Dale

Change your connection string to:

"data source=192.168.30.44;user=rocky;password=raccoon;initial
catalog=myDatabase"

You're trying to mix OleDb and SqlClient.

Search the .Net Framework documentation for an article titled "Accessing SQL
Server from a Web Application" and it will give you many examples of
connecting to SQL Server under differing conditions.

Dale
 
D

Dale

In my string, change "user=rocky" to "user id=rocky"

It's after midnight and until the reply posted, I didn't even catch my own
error.

Dale
 
S

Steve Kearney

Thanks for the reply Dale.

I've tried that connection string without success. There's something
odd going on... I think I have the syntax correct. I wonder if there's
some server setting I've neglected.

The same code works fine from a Windows app, but not from a webservice.
Very strange.

-Steve
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top