Skip to content Skip to sidebar Skip to footer

Connection Between Windows Service And Sql Database

I am trying to establishing a connection between a Windows service written in C# and a SQL Server Express database. But when connection.open is called I get this exception System

Solution 1:

When you execute your console application, the EXE runs under your user credentials. When you execute your service, which are user credentials? Is your service running under Locl Service Account? Or System? Or what? Try to manually set the credentials your service must run with (in Windows services panel, check your service properties) and try to execute it with the same user/pwd you run your console app with.

UPDATE taken from here: Using an User Instance on a local SQL Server Express instance The User Instance functionality creates a new SQL Server instance on the fly during connect. This works only on a local SQL Server 2005 instance and only when connecting using windows authentication over local named pipes. The purpose is to be able to create a full rights SQL Server instance to a user with limited administrative rights on the computer. I could think that your service credentials are not granted to create a new SQL server instance, so try to remove that part. Anyway, set user credentials on service properties and see what happens.

Post a Comment for "Connection Between Windows Service And Sql Database"