If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > accessing dll from a service

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-15-04, 13:55
eric2000 eric2000 is offline
Registered User
 
Join Date: Mar 2004
Posts: 11
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
Reply With Quote
  #2 (permalink)  
Old 03-16-04, 12:59
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
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
Reply With Quote
  #3 (permalink)  
Old 03-17-04, 09:15
eric2000 eric2000 is offline
Registered User
 
Join Date: Mar 2004
Posts: 11
oh, good point. i'll retest and see what happens. thanks!
Reply With Quote
  #4 (permalink)  
Old 03-17-04, 15:47
eric2000 eric2000 is offline
Registered User
 
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!
Reply With Quote
  #5 (permalink)  
Old 03-17-04, 16:35
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
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
Reply With Quote
  #6 (permalink)  
Old 03-22-04, 09:46
eric2000 eric2000 is offline
Registered User
 
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...
Reply With Quote
  #7 (permalink)  
Old 04-19-04, 13:25
eric2000 eric2000 is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On