Database update works as console app, fails as service

I wrote a console app that has a filewatcher, which takes an .xml document, extracts the data and updates my sql server 2005 DB. It works perfectly as a console app. I tried making it into a service, and it fails upon attempting a connection to SQL server giving me the following error:

Login failed for user...

I am using the same connection string for both programs. Is there anything special I have to do to let an NT Service connect to SQL Server? There is a lot of code, so if you need to see it, let me know what you would like to view.. thanks.

[570 byte] By [Yeshia] at [2007-12-24]
# 1

I believe that the Windows Service runs in a different account, and the account has not been given access permission in the database in SQL Server.

Are you using Windows Authentication/trusted connection by default? if so, I would suggest to create a seperate user account in SQL, then put the username/password of the user account created in SQL, in the connectionstring of the database in your application so it can connect to it using those credentials instead of the trusted_connection

does this help at all? What is the connection string you are using?

ahmedilyas at 2007-8-31 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2
It is probably an authentication problem related to the account under which the service was running. When the application runs as a console app the Windows account used is that of the user who is logged in and running the application. When it is a service it runs under the account specified at setup. Your alternatives are to setup the service using an account that is valid to the SQL Server or to use a "SQL server login". This is usually dependent upon your local security policies and the network protocol(s) you use. Any firewalls in place may affect your decision as well.
BradRoberts at 2007-8-31 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified