Wednesday, March 28, 2012

Named Pipes Provider, error: 40 - Could not open a connection

Ok,
I've spent a bunch of hours trying to figure out how to connect to SQL
Server 2005. I have MSDE 2005, IIS 6.0 and ASP.NET configured on my laptop.
I can run ASP.net code with no problem. I can access SQL Server from the
command line using osql with no problem.
But trying to access sql server 2005 from asp.net yields the following
message:
System.Data.SqlClient.SqlException: 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)
Can someone help me with this? I have both tcp/ip and named pipes enabled.
--
ThanksCan you post your connection string?
specifying
Network=DBMSSOCN
in your connection string will cause it to use tcp instead of named pipes,
which is less error prone.
See here for more details:
http://www.aspfaq.com/show.asp?id=2126
Also, check out the post regarding connections to sql express.
http://www.aspfaq.com/sql2005/show.asp?id=3
HTH
--
Ryan Powers
Clarity Consulting
http://www.claritycon.com
"Greg" wrote:
> Ok,
> I've spent a bunch of hours trying to figure out how to connect to SQL
> Server 2005. I have MSDE 2005, IIS 6.0 and ASP.NET configured on my laptop.
> I can run ASP.net code with no problem. I can access SQL Server from the
> command line using osql with no problem.
> But trying to access sql server 2005 from asp.net yields the following
> message:
> System.Data.SqlClient.SqlException: 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)
> Can someone help me with this? I have both tcp/ip and named pipes enabled.
> --
> Thanks|||The connections string is:
Cn = new SqlConnection("Network=DBMSSOCN;Data Source=192.168.1.103;Initial
Catalog=sqlexpress;Integrated Security=SSPI");
The new error message I get is:
(provider: TCP Provider, error: 0 - No connection could be made because the
target machine actively refused it.)
The detail is as follows:
System.Data.SqlClient.SqlException: 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: TCP Provider, error: 0 - No connection
could be made because the target machine actively refused it.)
It appears that the connection is blocked but I'm not sure where. I've
checked Windows Firewall and made sure that the appropriate ports are open...
--
Thanks
"Ryan Powers" wrote:
> Can you post your connection string?
> specifying
> Network=DBMSSOCN
> in your connection string will cause it to use tcp instead of named pipes,
> which is less error prone.
> See here for more details:
> http://www.aspfaq.com/show.asp?id=2126
> Also, check out the post regarding connections to sql express.
> http://www.aspfaq.com/sql2005/show.asp?id=3
> HTH
> --
> Ryan Powers
> Clarity Consulting
> http://www.claritycon.com
>
> "Greg" wrote:
> > Ok,
> >
> > I've spent a bunch of hours trying to figure out how to connect to SQL
> > Server 2005. I have MSDE 2005, IIS 6.0 and ASP.NET configured on my laptop.
> > I can run ASP.net code with no problem. I can access SQL Server from the
> > command line using osql with no problem.
> >
> > But trying to access sql server 2005 from asp.net yields the following
> > message:
> >
> > System.Data.SqlClient.SqlException: 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)
> >
> > Can someone help me with this? I have both tcp/ip and named pipes enabled.
> >
> > --
> > Thanks|||Check out this link.
http://blogs.msdn.com/sqlexpress/archive/2005/05/05/415084.aspx
This is a post that explains exactly how to enable remote connections for
express.
Ryan Powers
Clarity Consulting
http://www.claritycon.com
"Greg" wrote:
> The connections string is:
> Cn = new SqlConnection("Network=DBMSSOCN;Data Source=192.168.1.103;Initial
> Catalog=sqlexpress;Integrated Security=SSPI");
> The new error message I get is:
> (provider: TCP Provider, error: 0 - No connection could be made because the
> target machine actively refused it.)
> The detail is as follows:
> System.Data.SqlClient.SqlException: 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: TCP Provider, error: 0 - No connection
> could be made because the target machine actively refused it.)
> It appears that the connection is blocked but I'm not sure where. I've
> checked Windows Firewall and made sure that the appropriate ports are open...
> --
> Thanks
>
> "Ryan Powers" wrote:
> > Can you post your connection string?
> >
> > specifying
> > Network=DBMSSOCN
> > in your connection string will cause it to use tcp instead of named pipes,
> > which is less error prone.
> >
> > See here for more details:
> > http://www.aspfaq.com/show.asp?id=2126
> >
> > Also, check out the post regarding connections to sql express.
> > http://www.aspfaq.com/sql2005/show.asp?id=3
> >
> > HTH
> >
> > --
> > Ryan Powers
> > Clarity Consulting
> > http://www.claritycon.com
> >
> >
> > "Greg" wrote:
> >
> > > Ok,
> > >
> > > I've spent a bunch of hours trying to figure out how to connect to SQL
> > > Server 2005. I have MSDE 2005, IIS 6.0 and ASP.NET configured on my laptop.
> > > I can run ASP.net code with no problem. I can access SQL Server from the
> > > command line using osql with no problem.
> > >
> > > But trying to access sql server 2005 from asp.net yields the following
> > > message:
> > >
> > > System.Data.SqlClient.SqlException: 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)
> > >
> > > Can someone help me with this? I have both tcp/ip and named pipes enabled.
> > >
> > > --
> > > Thanks|||Excellent! I had to change from dynamic to static TCP port number. It works
great now.
Thanks for all your help
Greg
"Ryan Powers" wrote:
> Check out this link.
> http://blogs.msdn.com/sqlexpress/archive/2005/05/05/415084.aspx
> This is a post that explains exactly how to enable remote connections for
> express.
>
> --
> Ryan Powers
> Clarity Consulting
> http://www.claritycon.com
>
> "Greg" wrote:
> > The connections string is:
> > Cn = new SqlConnection("Network=DBMSSOCN;Data Source=192.168.1.103;Initial
> > Catalog=sqlexpress;Integrated Security=SSPI");
> >
> > The new error message I get is:
> > (provider: TCP Provider, error: 0 - No connection could be made because the
> > target machine actively refused it.)
> >
> > The detail is as follows:
> > System.Data.SqlClient.SqlException: 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: TCP Provider, error: 0 - No connection
> > could be made because the target machine actively refused it.)
> >
> > It appears that the connection is blocked but I'm not sure where. I've
> > checked Windows Firewall and made sure that the appropriate ports are open...
> >
> > --
> > Thanks
> >
> >
> > "Ryan Powers" wrote:
> >
> > > Can you post your connection string?
> > >
> > > specifying
> > > Network=DBMSSOCN
> > > in your connection string will cause it to use tcp instead of named pipes,
> > > which is less error prone.
> > >
> > > See here for more details:
> > > http://www.aspfaq.com/show.asp?id=2126
> > >
> > > Also, check out the post regarding connections to sql express.
> > > http://www.aspfaq.com/sql2005/show.asp?id=3
> > >
> > > HTH
> > >
> > > --
> > > Ryan Powers
> > > Clarity Consulting
> > > http://www.claritycon.com
> > >
> > >
> > > "Greg" wrote:
> > >
> > > > Ok,
> > > >
> > > > I've spent a bunch of hours trying to figure out how to connect to SQL
> > > > Server 2005. I have MSDE 2005, IIS 6.0 and ASP.NET configured on my laptop.
> > > > I can run ASP.net code with no problem. I can access SQL Server from the
> > > > command line using osql with no problem.
> > > >
> > > > But trying to access sql server 2005 from asp.net yields the following
> > > > message:
> > > >
> > > > System.Data.SqlClient.SqlException: 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)
> > > >
> > > > Can someone help me with this? I have both tcp/ip and named pipes enabled.
> > > >
> > > > --
> > > > Thanks

No comments:

Post a Comment