Data connection failed to open

Hello,

I'm attempting to install a Worker Service responsible for performing regular operations and communicating back and forth to a SQL Server 2005 database on a remote machine. I have a thin client that allows the user to make configurations, and although the first connection can take 20 seconds or so, the client succeeds at communicating with the database. The worker service, however, fails to do so every time.

On startup, I attempt to communicate with the server three times: 1) send the current time as the service's boot time, 2) send the current time as the service's "heartbeat", and 3) get outstanding items to process. The first two return the following error in the Application service log:

Data connection failed to open: database=xxx;server=XYZ\ABC;connection timeout=0;

The third one hangs indefinitely. Since this occurs on startup, the service is stuck in a perpetual "starting" status. When I change the timeout to a value, it does eventually timeout, which causes me to throw an exception and close the application.

I'm using the Enterprise Library with Visual Studio 2005.

Any suggestions as to how I can resolve this



Answer this question

Data connection failed to open

  • Jason Callas

    Enable trusted remote connections from SQL 2005 Management COnsole

    HTH



  • progrmr

    Have you tested your connection string to ensure that it is valid

    It should look something along these lines:

    Standard Security:

    "Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;"
    - or -
    "Server=Aron1;Database=pubs;User ID=sa;Password=asdasd;Trusted_Connection=False"
    (both connection strings produces the same result)

  • Trusted Connection:
    "Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;"
    - or -
    "Server=Aron1;Database=pubs;Trusted_Connection=True;"
    (both connection strings produces the same result)


  • JNG

    DMan1,

    I did add the "Trusted_Connection" parameter, but now that I'm using a set timeout, I retrieve the following:

    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)

    Any suggestions


  • William Bartholomew

    DMan1,

    I'm sorry, I didn't specify earlier: We're not using Trusted Connections. We're using Standard Security.


  • Swapna.B.

    That was the answer I was not looking forward to...

    This service is going to be used for deployment on a variable environment, which may be installed on as many as 30 machines. I would hate to have to walk a sysadmin through creating an account on each machine they choose to install it on.


  • MSP.Saami

    Run the service as a specified User account and give that account permissions in SQL...

    Ie setup an account called MyService give it the appropriate permissions in SQL and run the service under this account!



  • Vasanth Thangasamy

    It seems that the Local System account does not have appropriate permissions to contact a remote SQL Database. When I changed it to run under a user account, it was able to contact the database.

    Any ideas on how to work around this without requiring the service to run under a User account


  • Data connection failed to open