Getting an Error While Connecting the Sql Server 2005 from IIS

  • Hi all,

    I am Using Sql Server 2005.

    ** My database is in Server.

    I am able to connect to the server database from my machine in Design Mode. **

    I Created one Sample Web Service application and I have one method for getting the records from one table.

    I am able to connect the Sql Server 2005 and get the records from the database if i am running the page from Visual Studio.

    The Problem that i am facing is:

    I hosted the Sample Web Service application in IIS and tried to run it is throwing error message.

    The Error is :

    **

    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.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)

    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)

    at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject)

    at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)

    at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)

    at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)

    at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)

    at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)

    at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)

    at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)

    at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)

    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 Microsoft.Practices.EnterpriseLibrary.Data.Database.OpenConnection()

    at Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteReader(DbCommand command)

    at SeasonalWork.Data.Utility.ExecuteReader(Database database, DbCommand dbCommand)

    at SeasonalWork.Data.SqlClient.SqlWorktypesProviderBase.GetAll(TransactionManager transactionManager, Int32 start, Int32 pageLength, Int32& count)

    at SeasonalWork.Data.Bases.EntityProviderBaseCore`2.GetAll(TransactionManager mgr, Int32 start, Int32 pageLength)

    at SeasonalWork.Data.Bases.EntityProviderBaseCore`2.GetAll(TransactionManager mgr)

    at SeasonalWork.Data.Bases.EntityProviderBaseCore`2.GetAll()

    at SampleWebServiceapplication.Service1.GetWorktypes() in D:\NewSilverLightLists\SilverLight Components For GoldFlow\SampleWebServiceapplication\SampleWebServiceapplication\Service1.asmx.cs:line 39 **

    I Unstall and Install the Sql Server 2005 and IIS from my Machine

    then also the same Problem.

    But if i am not connecting to the database and return sample string message my service is running from iis.

    ** I checked all my Sql Server 2005 Setting in my machine and compare with my collegue machine setting(where it is working)

    it is same **

    I dont Know what is the Problem.

    I tried a alot for this Issue.

    I dont Know the Problem is with My IIS or My Sql Server 2005

    Can anybody help me out of this Problem Please.

    With Regards,

    kalyan

  • Have you verified that the Named Pipes provider is enabled using SQL Server Configuration Manager?

  • by default SQL Express doesn't allow connections via TCP/IP or Named Pipes, Only be Shared Memory. Depending on your connection string you may need to allow one or both of these. You can do this via the SQL server Configuration Manager.

    -Luke.

    To help us help you read this[/url]For better help with performance problems please read this[/url]

  • Thanks alot Luke for replying

    I enabled the Named Pipes and restart the Sql Server Express but no use it is throwing the Same Error

    kalyan

  • Thanks alot Jack for replying

    I enabled the Named Pipes and restart the Sql Server Express but no use it is throwing the Same Error

    kalyan

  • There is an article at Microsoft http://support.microsoft.com/kb/914277

    How to configure SQL Server 2005 to allow remote connections.

    It has a chapter:

    Enable remote connections for Sql Server 2005 Express.

    You may have to "Enable the SQL Browser service", as explained there

  • The error you mention is quite generic and I have certainly seen it occur when all Network protocols have been enabled.

    My guess is that the account this runs under from IIS does not have execute permissions on your SPs.

    If you can run it from within VS but not within IIS the problem will probably be related to the identity (user account) you are using.

    Check Impersonate identity settings in Web.Config. If you have deployed to IIS on a W2K3 server the application Pool account runs, by default, under NT Authority\Network Service. This will be different to an XP configuration which has no Application Pool and runs .Net code as ASPNET

  • Run your VS, then run the same test going through your website.

    Take a look in the security log on the SQL server and see what User ID is being used to connect.

    XP runs IIS5, W2003 runs IIS 6, and W2008 runs IIS 7

    Testing on machines running the same versions (Operating System / SQL server / Service Packs, etc) as what production would run also be recommended.

    Greg E

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply