none
login failed when accessing with windows service RRS feed

  • Frage

  • Hi,
    I have a problem accessing an SQL 2005 Express database with a Windows service. The following is the connection string:

    Server=MYMACHINE\SQLEXPRESS;Initial Catalog=MyDb;User Id=myUser;Password=myUser;

    "myUser" is configured as User under Security of the Database "MyDb".

    When I am logged in and start the service, the login is no problem. But when restarting the server, the service reports a login failure for the database.

    The Sql server is configured for Mixed authentication. The account in the connection string works. I can connect with the management studio with this user.

    I have no idea why the service cannot access the database when the server starts and why the service can access the database as soon as I am logged in on the server.

    Best regards and thanks for any help.

    Montag, 14. Juni 2010 13:32

Antworten

Alle Antworten

  • Hallo Yannik,

    Wie lautet die Fehlermeldung die Du bekommst?

    Grüße,

    Robert

    Montag, 14. Juni 2010 14:28
    Moderator
  • Hoi Robert

    Die meldung lautet in etwa: "The database "MyDb" could not be opened. The login failed for user 'myUser."

    Inzwischen habe ich den Verdacht, dass das ein maschinen spezifisches Problem ist. Ich konnte den fraglichen Windows Service auf einem Virtuellen XP und einem echten Windows 7 installieren und der kann beim neustart problemlos auf die lokale MS SQL 2005 Express datenbank zugreifen.

    Beim Installieren des SQL Server 2005 Express gibt es am Anfang eine option, ob man benutzern ohne admin rechte erlauben will, eine eigene Instanz zu starten.

    hat dies evtl. Einfluss auf das loginverhalten von Windows Services beim systemstart?

     

    Gruss und dank

    Yannik

    Montag, 14. Juni 2010 15:15
  • The Problem is solved. According to Thread http://social.msdn.microsoft.com/Forums/en-US/sqlsecurity/thread/85ef8cbc-4235-499a-bd64-bf424336d1a5 I have set the default database for the service user and now the login succeeds when starting automatically.
    Dienstag, 11. Januar 2011 11:13