UAC On, Service cannot connect to db

Discussion in 'microsoft.public.sqlserver.ce' started by kevwestwood, Jan 6, 2010.

  1. kevwestwood

    kevwestwood Guest

    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, Jan 6, 2010
    #1
    1. Advertisements

  2. 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.
     
    kevwestwood via SQLMonster.com, Jan 15, 2010
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.