Service written in Delphi 2006 that use ADO

Posted on 2008-10-10
Medium Priority
Last Modified: 2013-11-23
I'm writing a windows service using delphi 2006, the service need to make access to an postgre sql  database using ado.
I've, in the service, a TADOConnection, when I try to connect the database using
ADOConnection1.Connected := true i receive the error:

"Project Service1.exe raised exception class EOleException with message '[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified'."

The connection string is well placed because if i use the same connection string in a normal vcl application works fine.

The problem is in the service "architecture" i think that I must initialize something, but I don't know what, ie before that error delphi says me that i must call coinitialize to make it work, I've called it using the call:
Olecheck(CoInitialize(nil)); but after I've got the previous error.

Any idea to solve the problem?

Question by:maxc72
LVL 27

Assisted Solution

BigRat earned 200 total points
ID: 22687068
Normally Delphi provides everything needed to initialize and run a service. Clearly if the service thread is to run OLE then CoInitialize() must be called.

It could be however that the service is being run under a default account which has no access to the connectoon tables. Try adding the system login and password to the service (in the service console app)
LVL 15

Assisted Solution

mikelittlewood earned 200 total points
ID: 22687558
I usually create a specific network service account but if you want to give it database access you are going to either have to add it to a network group that also has access to the database or specifically name the user on the database.

Accepted Solution

maxc72 earned 0 total points
ID: 22701103
Thank's for your help, I've found the solution, the dns, was creater under "user dsn" so when the system account will try to find it, it was unable to do it, tha solution is to create a system dsn, now it works :)

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

587 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question