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,
(LPVOID *) &spCON);
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.
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.
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.
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.
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.