Article View: borland.public.cppbuilder.database.ado
Article #3827Re: ADO in threads
From: Arnie Mauer
Date: Tue, 04 Jun 2002 13:38
Date: Tue, 04 Jun 2002 13:38
27 lines
1954 bytes
1954 bytes
CoInitialize( 0 ) must be called by each thread to initialize the COM layer. When you drop one of the ADO objects on a form, this is done automatically for the man thread. My opinion would be to go with one connection per thread, especially if you're using transactions. - Arnie "Don Wilcox" <dwilcox@dfsaz.com> wrote in message news:3cfb8db2$1_1@dnews... > > I have a multi-threaded program that is going to need to update a SQL Server DB. How do I setup the connection objects for each thread? I tried creating a single connection object on the UI form and sharing it among the various threads. This doesn't give me any initial problems, but I worry about threading issues. > > I tried dropping a separate TADOConnection object on the UI form for each thread, but if the thread attempts to set Connected to true, the program raises the exception EOleException 'CoInitialize has not been called'. > > In short, what is the correct mechanism for using TADOConnections in multi-threaded apps? > > Thanks, > > Don
Technical Details
Message-ID:
<3cfcc2e4$1_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!supernews.com!news.airnews.net!cabal11.airnews.net!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<3cfb8db2$1_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,9e323c4b5b0bb71b X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2002-06-04 06:39:48 PST From: "Arnie Mauer" <amauer@vrms.com> Newsgroups: borland.public.cppbuilder.database.ado References: <3cfb8db2$1_1@dnews> Subject: Re: ADO in threads Date: Tue, 4 Jun 2002 09:38:55 -0400 Lines: 29 Organization: VRMS X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 209.140.211.97 Message-ID: <3cfcc2e4$1_1@dnews> X-Trace: dnews 1023197924 209.140.211.97 (4 Jun 2002 06:38:44 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!supernews.com!news.airnews.net!cabal11.airnews.net!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!dnews