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

Home Posts Topics Members FAQ

VB .net Service cannot connect to sql 2000

Ok guys I have racked my brain on this one.

I have a vb .net service installed on a win2k server. I am trying to
get it to connect to sql 2000 box but I get this error:

An error has occurred while establishing a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the
fact that under the default settings SQL Server does not allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not
open a connection to SQL Server)

I have remote connection turned on, on the sql2000. I have tried the
following connection strings

data source=<IP>;initial catalog=dfcdb;persist security info=False;user
id=user;password=PW;packet size=4096

data source=(local);initial catalog=dfcdb;persist security
info=False;user id=user;password=PW;packet size=4096

data source=tcp:<IP>;initial catalog=dfcdb;persist security
info=False;user id=user;password=PW;packet size=4096

data source=<IP>:1433;initial catalog=dfcdb;persist security
info=False;user id=user;password=PW;packet size=4096 (that port is
open)

The service is set to run under my log on.

I made a windows app that tests connection strings and the first 3
work. I tested the service on a local machine with a local sql 2000 and
it works like a champ.

Here is the .net code to open the connection

'1. Create a connection
Dim SQLString As String = My.Settings.SQLConnectionString
Dim cn As New SqlConnection(SQLString)

cn.Open() <-- I think it breaks here
'2. Create the command object, passing in the SQL string
Const selectString As String = "GetRules"
Dim cmd As SqlCommand
cmd = New SqlCommand(selectString, cn)
cmd.CommandType = CommandType.StoredProcedure

Dim reader As SqlDataReader = cmd.ExecuteReader()

please help I have looked everywhere

Jan 8 '07 #1
10 2327
Have you made sure that the connection can get through your firewall?
<bl*********@gmail.comwrote in message
news:11*********************@38g2000cwa.googlegrou ps.com...
Ok guys I have racked my brain on this one.

I have a vb .net service installed on a win2k server. I am trying to
get it to connect to sql 2000 box but I get this error:

An error has occurred while establishing a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the
fact that under the default settings SQL Server does not allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not
open a connection to SQL Server)

I have remote connection turned on, on the sql2000. I have tried the
following connection strings

data source=<IP>;initial catalog=dfcdb;persist security info=False;user
id=user;password=PW;packet size=4096

data source=(local);initial catalog=dfcdb;persist security
info=False;user id=user;password=PW;packet size=4096

data source=tcp:<IP>;initial catalog=dfcdb;persist security
info=False;user id=user;password=PW;packet size=4096

data source=<IP>:1433;initial catalog=dfcdb;persist security
info=False;user id=user;password=PW;packet size=4096 (that port is
open)

The service is set to run under my log on.

I made a windows app that tests connection strings and the first 3
work. I tested the service on a local machine with a local sql 2000 and
it works like a champ.

Here is the .net code to open the connection

'1. Create a connection
Dim SQLString As String = My.Settings.SQLConnectionString
Dim cn As New SqlConnection(SQLString)

cn.Open() <-- I think it breaks here
'2. Create the command object, passing in the SQL string
Const selectString As String = "GetRules"
Dim cmd As SqlCommand
cmd = New SqlCommand(selectString, cn)
cmd.CommandType = CommandType.StoredProcedure

Dim reader As SqlDataReader = cmd.ExecuteReader()

please help I have looked everywhere

Jan 9 '07 #2
To be honest I really don't know much about firewalls and I think that
might be the problem. What would I need to set on it for it to work?
Matt Fielder wrote:
Have you made sure that the connection can get through your firewall?
<bl*********@gmail.comwrote in message
news:11*********************@38g2000cwa.googlegrou ps.com...
Ok guys I have racked my brain on this one.

I have a vb .net service installed on a win2k server. I am trying to
get it to connect to sql 2000 box but I get this error:

An error has occurred while establishing a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the
fact that under the default settings SQL Server does not allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not
open a connection to SQL Server)

I have remote connection turned on, on the sql2000. I have tried the
following connection strings

data source=<IP>;initial catalog=dfcdb;persist security info=False;user
id=user;password=PW;packet size=4096

data source=(local);initial catalog=dfcdb;persist security
info=False;user id=user;password=PW;packet size=4096

data source=tcp:<IP>;initial catalog=dfcdb;persist security
info=False;user id=user;password=PW;packet size=4096

data source=<IP>:1433;initial catalog=dfcdb;persist security
info=False;user id=user;password=PW;packet size=4096 (that port is
open)

The service is set to run under my log on.

I made a windows app that tests connection strings and the first 3
work. I tested the service on a local machine with a local sql 2000 and
it works like a champ.

Here is the .net code to open the connection

'1. Create a connection
Dim SQLString As String = My.Settings.SQLConnectionString
Dim cn As New SqlConnection(SQLString)

cn.Open() <-- I think it breaks here
'2. Create the command object, passing in the SQL string
Const selectString As String = "GetRules"
Dim cmd As SqlCommand
cmd = New SqlCommand(selectString, cn)
cmd.CommandType = CommandType.StoredProcedure

Dim reader As SqlDataReader = cmd.ExecuteReader()

please help I have looked everywhere
Jan 9 '07 #3
Just as a test to see if that is in fact the issue, just disable the
firewall entirely for a test - then re-enable. Once you've figured out if
that is the issue, you can do a little more research about how to allow just
the needed access through. Others know much more about this type of
security than I, so I don't want to potentially give dangerous advice.

For the quick test, if your running the firewall built into XP, you can get
to it via control panel.

"blurryimage" <bl*********@gmail.comwrote in message
news:11**********************@m30g2000cwm.googlegr oups.com...
To be honest I really don't know much about firewalls and I think that
might be the problem. What would I need to set on it for it to work?
Matt Fielder wrote:
>Have you made sure that the connection can get through your firewall?
<bl*********@gmail.comwrote in message
news:11*********************@38g2000cwa.googlegro ups.com...
Ok guys I have racked my brain on this one.

I have a vb .net service installed on a win2k server. I am trying to
get it to connect to sql 2000 box but I get this error:

An error has occurred while establishing a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the
fact that under the default settings SQL Server does not allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not
open a connection to SQL Server)

I have remote connection turned on, on the sql2000. I have tried the
following connection strings

data source=<IP>;initial catalog=dfcdb;persist security info=False;user
id=user;password=PW;packet size=4096

data source=(local);initial catalog=dfcdb;persist security
info=False;user id=user;password=PW;packet size=4096

data source=tcp:<IP>;initial catalog=dfcdb;persist security
info=False;user id=user;password=PW;packet size=4096

data source=<IP>:1433;initial catalog=dfcdb;persist security
info=False;user id=user;password=PW;packet size=4096 (that port is
open)

The service is set to run under my log on.

I made a windows app that tests connection strings and the first 3
work. I tested the service on a local machine with a local sql 2000 and
it works like a champ.

Here is the .net code to open the connection

'1. Create a connection
Dim SQLString As String = My.Settings.SQLConnectionString
Dim cn As New SqlConnection(SQLString)

cn.Open() <-- I think it breaks here
'2. Create the command object, passing in the SQL string
Const selectString As String = "GetRules"
Dim cmd As SqlCommand
cmd = New SqlCommand(selectString, cn)
cmd.CommandType = CommandType.StoredProcedure

Dim reader As SqlDataReader = cmd.ExecuteReader()

please help I have looked everywhere

Jan 9 '07 #4
I just looked at the server and no firewall is running on it.

Jan 10 '07 #5
Can you connect to the server from teh remote machine through either the
Server Explorer in VS or SQL Enterprise Manager?

"blurryimage" <bl*********@gmail.comwrote in message
news:11*********************@i39g2000hsf.googlegro ups.com...
>I just looked at the server and no firewall is running on it.

Jan 11 '07 #6
I just ran another test and it does not make sense. I ran the service
from an outside the network machine using the public IP of the SQL
server and it runs fine. I dont understand why a pc not on the network
can connect but a service on the same machine cannt connect.

I am using internal IP in connection string for the locally ran service
and the external public IP for the service being ran outside the
network.

I dont have VS installed on the server to test its connection but I can
publish to it from VS on an external machine

Jan 11 '07 #7
A few things to look at:

Are you able to ping the IP address that you're using in your connection
string?
If unable to connect when running on local machine, try changing the IP in
your connection string to 127.0.0.1.
Also try changing datasource in connect string to "localhost"

I suspect that the local IP address your attempting to connect to may not be
correct. I'd double check that as well.

"blurryimage" <bl*********@gmail.comwrote in message
news:11**********************@i56g2000hsf.googlegr oups.com...
>I just ran another test and it does not make sense. I ran the service
from an outside the network machine using the public IP of the SQL
server and it runs fine. I dont understand why a pc not on the network
can connect but a service on the same machine cannt connect.

I am using internal IP in connection string for the locally ran service
and the external public IP for the service being ran outside the
network.

I dont have VS installed on the server to test its connection but I can
publish to it from VS on an external machine

Jan 11 '07 #8
Thank you for your help on this.

I tried 127.0.0.1 and local and localhost with no luck. I also did an
ipconfig just to make sure it is the right address and it is.

I have a windows app that I made to test SQL connection strings It just
tells if the connection was made returning True or False. This program
(running as a windows app) works so I know the connection strings are
good. I run into the connection problem only when it is a windows
service.

Jan 11 '07 #9
I hate to say it but I'm running out of ideas. There is always the "call
microsoft" option - although probably a costly one. I did google and ran
accross a few issues that people have had, but most seem to be resolved via
SQL service packs. If I think of anything else, I'll post back. I'm also
watching this thread because now I'm both curious and stumped. Please post
the solution if you find one. Sorry I couldn't be more help -- good luck!!!

"blurryimage" <bl*********@gmail.comwrote in message
news:11**********************@k58g2000hse.googlegr oups.com...
Thank you for your help on this.

I tried 127.0.0.1 and local and localhost with no luck. I also did an
ipconfig just to make sure it is the right address and it is.

I have a windows app that I made to test SQL connection strings It just
tells if the connection was made returning True or False. This program
(running as a windows app) works so I know the connection strings are
good. I run into the connection problem only when it is a windows
service.

Jan 11 '07 #10
Just a few problems that I have ran into, it might help, and it might
not help.

1. Some web hosts, do not allow adhoc connections to databases. I'm
sure this is not your problem. But, I have experienced web hosting
that does not support this in the past.

2. I think I have received an error similiar to your when one of the
sql services on the server was not running. I think the service name
was "sql server browser". It was not running and caused that issue.

Trouble shooting:
You could check and see if you can connect to the sql server, using the
..net server explorer. If you can not connect to the server.

In the past when I had a problem and could not connect to a server, I
uninstalled sql and then re-installed it.
Matt F wrote:
I hate to say it but I'm running out of ideas. There is always the "call
microsoft" option - although probably a costly one. I did google and ran
accross a few issues that people have had, but most seem to be resolved via
SQL service packs. If I think of anything else, I'll post back. I'm also
watching this thread because now I'm both curious and stumped. Please post
the solution if you find one. Sorry I couldn't be more help -- good luck!!!

"blurryimage" <bl*********@gmail.comwrote in message
news:11**********************@k58g2000hse.googlegr oups.com...
Thank you for your help on this.

I tried 127.0.0.1 and local and localhost with no luck. I also did an
ipconfig just to make sure it is the right address and it is.

I have a windows app that I made to test SQL connection strings It just
tells if the connection was made returning True or False. This program
(running as a windows app) works so I know the connection strings are
good. I run into the connection problem only when it is a windows
service.
Jan 12 '07 #11

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

Similar topics

0
by: Jack Smith | last post by:
Hello, I have PHP 4.3.1.1 running on Windows 2000 Server with IIS 5. This connects to an MS SQL 7 server running on a seperate NT4 box. Recently, this SQL7 Server had SQL7 Service Pack 4...
1
by: Subodh | last post by:
Hi, I changed the login for MSSQLSERVER service for 6.5 box to "This account" from "system account" and then again changed back to "system account". Now I cann't connect thru Enterprize Manager...
2
by: Jay Chan | last post by:
We have just installed a SQL Server 2000 (SP 3A) onto a computer that has Windows-2003 Server on it. Now, we cannot get access to that database server from other computers. Seem like this may be an...
3
by: Steve Lutz | last post by:
Hi All, I have a Windows Service that runs well. The service hosts a remote object. The purpose of the object is so that I can "peak" into the service to see what it's doing. I wrote a small...
1
by: Scott McChesney | last post by:
Folks - We are running around and around here on a project we're developing, and I'm getting to the point that I don't know what I do and don't know. So I need some assistance. We are...
3
by: Richard | last post by:
I have created a Windows service which performs various functions including setting variables in other application objects. When the service runs under Local System account the functionality all...
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...
8
by: Manfred Braun | last post by:
Hello All! I am writing a management application, which has to access remote machines registry via System.Diagnostics.EventLog.CreateEventSource . For each machine, I connect to, I create a...
1
by: bitchanger | last post by:
I have installed an SQL Server 2000 Developer Edition (SP4) on a computer that has Windows Server 2003 on it.The server is connected to the workgroup "WORK" and has no Active Directory. Now I...
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.