Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > SQLConnection.Open() in a WebService

Reply
Thread Tools

SQLConnection.Open() in a WebService

 
 
Stephen
Guest
Posts: n/a
 
      07-16-2004
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!
 
Reply With Quote
 
 
 
 
Dale
Guest
Posts: n/a
 
      07-18-2004
Change your connection string to:

"data source=192.168.30.44;user=rocky;password=raccoon;i nitial
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


"Stephen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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!



 
Reply With Quote
 
 
 
 
Dale
Guest
Posts: n/a
 
      07-18-2004
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

"Dale" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> Change your connection string to:
>
> "data source=192.168.30.44;user=rocky;password=raccoon;i nitial
> 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
>
>
> "Stephen" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > 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!

>
>



 
Reply With Quote
 
Steve Kearney
Guest
Posts: n/a
 
      07-19-2004
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



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem to call a WEBSERVICE in another WEBSERVICE (AXIS/ TOMCAT) Cyril Java 2 06-01-2006 06:07 PM
Problem! webservice.htc calling nonsecure webservice from a secured ssl https webpage batista ASP .Net 1 01-26-2006 12:05 PM
Problem! webservice.htc calling nonsecure webservice from a secured ssl https webpage batista ASP .Net 0 01-26-2006 08:13 AM
WebService on Java server versus WebService on .NET Mr. x Java 2 10-09-2003 11:21 PM
use another webservice in a webservice Mr. x ASP .Net Web Services 0 09-26-2003 10:59 PM



Advertisments