Delphi "coinitialize not called" SOLUTION

Source: Internet
Author: User

This error occurs when you use com or call the ADO control. It is usually a program problem. After COM is called, The OLE function library must be called before coinitialize, because in the application, Delphi will automatically add a call to the CO... function in the initialize unit, and you must call it in the DLL.

However, the following code in the pubdbconn in Delphi prompts that "coinitialize has not been called"

Procedure createadocsql;
Begin
Adocsql: = tadoconnection. Create (NiL );
Try
If adocsql. connected then
Adocsql. close;
Adocsql. connectionstring: = stris;
Adocsql. loginprompt: = false;
Adocsql. Connected: = true;
Adocsql. commandtimeout := 600;
Except
On E: eoleexception do
Application. MessageBox (pchar (E. source), pchar (E. Message), mb_ OK + mb_iconstop );
End;
End;

Initialization

Createadocsql;
End.

Finally, coinitialize (NiL) and couninitilize () are added before and after createadocsql, that is

Try
Coinitialize (NiL );
Createadocsql;
Finally
.....
Couninitialize;
End;

Of course, uses ActiveX is required in the unit.

From: http://blog.csdn.net/trassion/article/details/9712389

Delphi "coinitialize not called" SOLUTION

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.