Article View: borland.public.cppbuilder.database.ado
Article #1978Re: Creating MS Access Database (revisited)
From: Viatcheslav V. Vassiliev
Date: Fri, 09 Jan 2004 09:55
Date: Fri, 09 Jan 2004 09:55
63 lines
2970 bytes
2970 bytes
>>CheckSafecallResult(HRESULT hr)
It is a fix for BCB6.
>>CoInitiliaze()/CoUninitialize()
It is COM initialization. These function should be called in every thread.
COM unit calls CoInitialize() (or CoInitializeEx()) function in InitProc. In
GUI application InitProc is called in Application.Run. In console
application you may call
if InitProc <> nil then TProcedure(InitProc);
as first procedure.
Using ComObj has some advantages - it can call CoInitialize() or
CoInitializeEx() with needed parameters (see CoInitFlags in ComObj).
In DLL CoInitialize()/CoUninitialze() may need to be called too. But it is
better to call them from main application - Microsoft does not recommend
call them from DllMain (initialization/finalization sections in Delphi).
Calling these funcions from main application lets main application to
initialize COM with needed parameters.
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi + ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"Simon Elliott" <simon@nospam.demon.co.uk> �������/�������� � ��������
���������: news:zPKJWAAuwb$$IwSU@courtlands.demon.co.uk...
> Viatcheslav V. Vassiliev <support@oledbdirect.com> writes
> >You may also need to add
> >
> >#include <comobj.hpp>
> >
> >namespace System
> >{
> > void __fastcall CheckSafecallResult(HRESULT hr)
> > {
> > OleCheck(hr);
> > }
> >}
>
> What does the above do?
>
> >CoInitialize()/CoUninitialize() - do not call them, just include ComObj
> >unit. They are needed only in dlls.
>
> I've found that when running ADO in a separate thread, or in a console
> mode program, an exception is thrown if CoInitialize is not called.
> --
> Simon Elliott
> http://www.ctsn.co.uk/
>
>
>
>
>
>
Technical Details
Message-ID:
<3ffe7b67@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<DlNlsBA9AB8$Iwut@courtlands.demon.co.uk> <3ffd3ee0@newsgroups.borland.com> <3ffd7a14@newsgroups.borland.com> <zPKJWAAuwb$$IwSU@courtlands.demon.co.uk>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10698b,1386b963f53820e2 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2004-01-09 02:09:28 PST From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <DlNlsBA9AB8$Iwut@courtlands.demon.co.uk> <3ffd3ee0@newsgroups.borland.com> <3ffd7a14@newsgroups.borland.com> <zPKJWAAuwb$$IwSU@courtlands.demon.co.uk> Subject: Re: Creating MS Access Database (revisited) Date: Fri, 9 Jan 2004 12:55:05 +0300 Lines: 65 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 213.234.218.42 Message-ID: <3ffe7b67@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1073642343 213.234.218.42 (9 Jan 2004 01:59:03 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail