Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2004
    Posts
    11

    Unanswered: accessing dll from a service

    I'm a new user so not sure if this has been asked before...here is my problem: i have created a service which uses a DLL that I've written with a co-worker. This DLL has ADO calls and when my program is just running as a console program and not as a service, the DLL works fine (can execute my stored procedures successfully). When I run my program as a service, the CreateInstance for the connection to the database does not complete
    hr = CoCreateInstance(CLSID_CADOConnection,
    NULL,
    CLSCTX_INPROC_SERVER,
    IID_IADOConnection,
    (LPVOID *) &spCON);

    Can anyone tell me what I'm doing wrong?

    Thanks
    Eric2000

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    My guess would be that you are using integrated security. When you run interactively, the NT user has permission to connect to the database. When you run as a service, you probably don't impersonate any NT login, so you run as localSystem which may not have permission to connect to the database.

    -PatP

  3. #3
    Join Date
    Mar 2004
    Posts
    11
    oh, good point. i'll retest and see what happens. thanks!

  4. #4
    Join Date
    Mar 2004
    Posts
    11
    One question: my dll fails at the point where I'm trying to execute CreateInstance (Connection) Would this still involve user ids at this point?
    The connectionString contained a SQL logon id and password and not the Windows ID credentials.

    Thanks again for any help!

  5. #5
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Is it possible that your service starts before SQL Server can accept logins? When you installed the service using SCM did you make SQL Server a dependancy?

    The easiest way to test this is to manually start your service. Since the system is already far enough into the startup sequence to allow user logins, you know that SQL Server will already be started. If your service starts then, you need to work on your dependancy list.

    -PatP

  6. #6
    Join Date
    Mar 2004
    Posts
    11
    Thanks PatP for your replies...at this point in testing, my service is running on my Windows NT workstation (this is also where my DLL is located) and the SQL server (which is always up and running) is running on a server in our lab.

    thanks again...

  7. #7
    Join Date
    Mar 2004
    Posts
    11
    Found out that in my DLL, I was using MessageBox but didn't know that they don't show up when program runs as a service although my first 2 MessageBoxes did show up??? Thanks everyone for you suggestions and help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •