Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting to ADO in a thread

Status
Not open for further replies.

Grudge

Programmer
Jul 30, 2002
23
0
0
ZA
Hey Guys,

I'm trying to connect to a SQL database, using ado inside a threads execute statement, but it's not working. I'm not sure if I can do this, can I ? Thanks,
 
I get the error "CoInitialize not called" when I do this in a thread. I don't get this error in a normal application. This is the execute code from the query :

void __fastcall ThreadTest::Execute()
{
Message = "Thread Started";
Synchronize( LogMessage );

ADOConnection = new TADOConnection(NULL);
ADOConnection->ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=localMO;Data Source=SCEPC\SQLDEV";
ADOConnection->Open();

// ...


Message = "Thread Finished";
Synchronize( LogMessage );

}

Any help would be appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top