1

I am trying to connect SQL Server from a Windows service. Now my Windows service is installed in different system. Now if I want to connect to my SQL Server, how can I connect? I am able to connect if I add the respective system userid in the SQL Server login users. I don't think that is the right way..because if i required to install the windows service in different system again I need to add that user to SQL Server.

2 Answers 2

1

I presume you are using InstallUtil to install the service. You should configure the service to run under a domain account. Let's call this YourDomain\WindowsServiceDomanAccount

In the connection string, use the tag INTEGRATED SECURITY=SSPI

On the SQL Server, create a login for YourDomain\WindowsServiceDomanAccount and grant it appropriate permissions.

You server should be configured for remote connections to allow non-local connections.

Sign up to request clarification or add additional context in comments.

Comments

0

Unless you're using trusted connections then the install process should request the credentials that should be used on that system.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.