Login failed for user 'xyz' when a windows service tries to connect to local database


  • Hi

    I have created a windows service that calls another class (which sends emails daily after checking the database for subscribers). This service runs under Local System account and set to automatic. When i change the logon account to Network service, i get the same errors.

    My first problem is : when i bootup(shut down and then start again) my system, the service does start automatically but gives me an exception - 'login failed for the user'. Although i have this user set up in the database with db_owner rights and i can login to sql server with this login fine.

    2. when i restart my system, sql server isn't started so gives me a different exception - cannot connect to database.

    3. when i manually start the service with sql server running (either automatically or manually), i get the required emails.

    4. when i try a different box to see if the service works there, the service starts and stops automatically..even though, the database is configured to allow remote connections and i also changed the connection string ="Server=<machinename>;User ID=<userid>;Password=<pwd>;Initial Catalog=<dbname>".

    I am new to windows services and sql server so any help is appreciated.


    • Edited by Natty PLC Friday, April 27, 2012 7:41 PM
    Friday, April 27, 2012 7:01 PM


All replies