Error while connecting to SQL 2005 from ASP.Net 2.0

G

Guest

Hi,

I am not sure whether this is the correct newsgroup where I need to post my
question. Let me know where I need to post for a quick response.

I get the following error when I try to connect to SQL 2005 from my ASP.Net
2.0 application.

System.Web.Services.Protocols.SoapException: Server was unable to process
request. ---> 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)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable,
IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)

Can anyone help me on this issue. Thanks in advance.

Regards,
Sriram Mallajyosula
 
S

Steven Cheng[MSFT]

Hello Sriram,

According to the error message/callstack you attached, the direct exception
is a "SoapException", so I think your ASP.NET web application is calling
another ASP.NET webservice webmethod, correct?

As the SoapException's inner error message show the following error:

=========
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.
=============

I think the root cause of the problem is the data accessing from the
ASP.NET webservice to the SQL Server 2005 box. Is the webservice
application on the same machine as your ASP.NET web application and the SQL
Server on a remote server? If so, as the error message indicate, the SQL
Server 2005 currently disallow remote connection to it. For SQL server
2005 (express or developer edition), by default, it only enable remote
connection for TCP/IP protocol, and TCP/IP is not enabled by default. I
suggest you use "SQL Server Configuration Manager" to check the server
protocols and ensure that both named pipe and TCP/IP are enabled. And use
the "SQL Server Surface Area Configuration" tool to configure the SQL
Server instance to allow remote connection (at least for TCP/IP connection).

Here is a knowledge base article discussing on this:

#How to configure SQL Server 2005 to allow remote connections
http://support.microsoft.com/kb/914277/en-us

If you have anything unclear on this or if the problem here has other
particular symptoms, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Steven Cheng[MSFT]

Hello Sriram,

Have you got any progress on this issue? As for the information posted in
the previous reply, did they help you some? If there is anything else we
can help, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Hi Steven,

The issue is not resolved yet. As you have suggested I need to check the
"SQL 2005 Surface Area Configuration" on the server and see what could be the
problem.
 
S

Steven Cheng[MSFT]

Thanks for your reply Sriram,

If you get any progress or meet any further problem that we can help,
please feel free to post here.

Look forward to your reply.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Hi Steven,

It is working now. Actually we had added the production SQL 2005 server with
port 8701 under the "SQL Client Network Utility" present in SQL 2000. Also I
just wanted to confirm whether this setup needs to be done on the web server
or the database server. Because the ASP.Net 2.0 application present in the
web is accessing a remote database server (SQL 2005).

Regards,
Sriram Mallajyosula
 
S

Steven Cheng[MSFT]

Thanks for your quick reply Sriram,

Glad that you've fixed the problem. For server-side SQL Server setting, as
that KB article has mentioned, if the remote SQL Server is of developer
edition, the remote connection for TCP IP is not enabled, you need to check
the "SQL 2005 Surface Area Configuration", for enterprise server edition,
this should be enabled by default. But you're recommended to confirm this.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top