Article View: borland.public.cppbuilder.database.ado
Article #4648Problem: using ADOConnection in a thread
From: Alexander Chow
Date: Wed, 24 Oct 2001 03:54
Date: Wed, 24 Oct 2001 03:54
25 lines
1902 bytes
1902 bytes
Hi, all
I have met a strange problem when using ADOConnection in a thread and I
have written a simple application to show this.
1. Create a new application, then new a thread object with a name of
TestThread.
2. Put a TADOConnection and a TButton on the form, and write a line in
buttonclick:
TestThread * pTestThread = new TestThread(false);
3. In TestThread's execute method, write this:
try {
// My connectionstring is set to connect to a sql server
// and not shown here
Form1->ADOConnection1->ConnectionString = "Provider=...";
Form1->ADOConnection1->Open();
}
catch(...)
{
ShowMessage("Error!");
}
4. Run it, when you press the button to make a connection to a sqlserver
from the thread, an EOleException is thrown.
I have also tried to connect to sql server with the same code without
using a thread, it succeeds. And I have installed borland's ADOExpress
pack1, but the error still happens.
Does anybody have a solution or suggestion?
Technical Details
Message-ID:
<3bd63b2e_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnewsShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,8497a58d37414a68,start X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2001-10-23 21:00:38 PST Reply-To: "Alexander Chow" <zhou.zheng@dcecom.com.cn> From: "Alexander Chow" <zhou.zheng@dcecom.com.cn> Newsgroups: borland.public.cppbuilder.database.ado Subject: Problem: using ADOConnection in a thread Date: Wed, 24 Oct 2001 11:54:04 +0800 Lines: 27 Organization: delta 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: 210.78.28.61 Message-ID: <3bd63b2e_1@dnews> X-Trace: dnews 1003895598 210.78.28.61 (23 Oct 2001 20:53:18 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews