Discussion:
UAC On, Service cannot connect to db
(too old to reply)
kevwestwood
2010-01-06 23:02:38 UTC
Permalink
We have two C# apps. One winforms gui app and a service installed under the
LocalSystem account. Each needs to be able to connect to the same SQL Server
CE database.

With UAC turned on, if the gui app connects first, the service cannot connect
and we get the error "Database already opened by a different user". However,
if the service connects to the database first, then the gui app can connect
just fine.

If we run the gui app as an administrator and connect first, the service can
connect. However, we do not want to force the user to run the gui app as an
administrator. We have tried to install the service under different accounts,
including the same account that the user is running under, but it makes no
difference.

Does anyone know a solution to this problem? Is this a SQL Server CE bug?
kevwestwood via SQLMonster.com
2010-01-15 00:36:12 UTC
Permalink
There appears to be know elegant fix for this. We ended up just working
around the problem.

SQLCe will not allow an application run as an administrator to connect if a
standard user application had already connected. (Our application is a
service, and services always run with certain administrative rights.) SQLCe
determines that the service is being run by a different user. If the service
connects first then the standard application can connect just fine.

What we did is just force the order of the connections. If the service fails
to connect and the error code is 25117 (already opened by a different user).
Using some inter-process communication the following occurs:

1)The standard app disconnects
2)The service connects
3)The standard app reconnects.
Post by kevwestwood
We have two C# apps. One winforms gui app and a service installed under the
LocalSystem account. Each needs to be able to connect to the same SQL Server
CE database.
With UAC turned on, if the gui app connects first, the service cannot connect
and we get the error "Database already opened by a different user". However,
if the service connects to the database first, then the gui app can connect
just fine.
If we run the gui app as an administrator and connect first, the service can
connect. However, we do not want to force the user to run the gui app as an
administrator. We have tried to install the service under different accounts,
including the same account that the user is running under, but it makes no
difference.
Does anyone know a solution to this problem? Is this a SQL Server CE bug?
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-ce/201001/1
Loading...