Board index » delphi » Newbie? Question about ADO

Newbie? Question about ADO


Im new to ADO.
Everytime I try to use TADOCommand.Execute I get an exception which says
something like:
"CoInitialize wasnt executed"

Can someone give me a hint what CoIitialize is ?

thanks in advance

Johannes Pucher


Re:Newbie? Question about ADO

>Im new to ADO.
>Everytime I try to use TADOCommand.Execute I get an exception which says
>something like:
>"CoInitialize wasnt executed"

>Can someone give me a hint what CoIitialize is ?

CoInitialize is the method to initialize COM.
Normally this is taken care of in your project file with the line

If you are doing something like a dll you have to call coInitilaize in your code
You need the unit ActiveX
and you need to call CoUninitialize when your done
Brian Bushay (TeamB)

Re:Newbie? Question about ADO

I don't know if this will help or not but the following is cut from an
answer that I gave to another person what was having trouble with EXE's
calling DLL's.

The reason you are having trouble is you are now trying to open a DLL from
an EXE.  This only normally happens when you have databases (in DataModules)
to open in the DLL. Because I have created applications that don't open or
use databases and have not had any problems opening Forms, Procedures or
Functions.  I know this is a simple answer but I really do not know why you
need the following code added.  All I know is that it works.

Try this:

at the Uses directly below Initialize, add the following ACTIVEX ( I used to
use OLE2 but I found that Activex had it already)

Then at the bottom of your main.pas file directly before the last end(the
one with the period) the following code

end.  // this 'end' was added just to show you the proper position don't add
it again

I have fumbled around with DLL's for the last year and finally found all I
need to have to create EXE's and DLL's (Static and Dynamic) that Work
together.  If you need more help contact me directly and I will send you
sample code to help you along.

Hope this helps

Bob Wasaff
Firetree LTD

Other Threads