Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Database/dbExpressCore    [ Add a report in this area ]  
Report #:  80811   Status: Closed
Remote error: DBX Error - Multi-threaded MSSQL dbExpress Driver Usage
Project:  Delphi Build #:  14.0.3539.24502
Version:    14.0 Submitted By:   John-Arne Gangås
Report Type:  Crash / Data loss / Total failure Date Reported:  1/4/2010 2:24:26 AM
Severity:    Critical / Show Stopper Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   253362
Resolution: Test Case Error (Resolution Comments) Resolved in Build: : 11.0.2796.9108
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
Remote error: DBX Error:  Driver could not be properly initialized.  Client library may be missing, not installed properly, or of the wrong version.

Datasnap

Added by Sysop
<<<<<<<<<<<<<<<
This issue is related to this KB.
[Multi-threaded MSSQL dbExpress Driver Usage]
http://edn.embarcadero.com/en/article/37092

dbExpress drivers for MS SQL Server(dbxmss.dll, dbxmss9.dll) of Delphi 2010 do NOT call CoInitialize(Ex) API before making a connection.
On the other hand, drivers of Delphi 2007, 2009 do call CoInitialize API with its default parameter before making a connection.
But, generally speaking, user application which uses OLE/COM layer needs to call CoInitialize(Ex) explicitly with its proper parameters.

Please see comments of QC for more detail and its workaround.
>>>>>>>>>>>>>>>


Added by Sysop
<<<<<<<<<<<<<<<
https://forums.embarcadero.com/thread.jspa?threadID=30178&tstart=0
>>>>>>>>>>>>>>>
Steps to Reproduce:

Added by Sysop
<<<<<<<<<<<<<
I have set up a datasnap server that exposes a dataset through a DataSetProvider.
Connects to the database with TSQLConnection (SQL Server 2005)
I have installed native client 2008

On the client I add an TClientDataset that should connect to the provider on the server
In the ClientDS i can select the providername from the dropdown list.
But if i try to activate the ClientDS i get this error:

Remote Error: DBX Error: Driver could not be properly initialized. Client library may be missing, not installed properly, or of the wrong version.

Previously I also got this error message when trying to connect to the DB with TSQLConnection.
That's why I installed native client 2008.
>>>>>>>>>>>>>
Workarounds
None
Attachment
TestProject.zip
Comments

John-Arne Gangås at 1/8/2010 1:08:21 AM -
Sems like if I also add an dummy TADOConnection at the server and set it up to the same database. And set it to active=true.
It work fine

Tomohiro Takahashi at 1/8/2010 6:11:58 AM -
What RDBMS do you connect to, for exmaple MS SQL Server 2008?
And, could you please attach a simplest sample project to understand your issue?

If you use SQL Server, you may need to call CoInitialize(Ex)/CoUninitialize for each thread context, especially, worker thread.
I guess this KB is related to your situation..
[Multi-threaded MSSQL dbExpress Driver Usage]
http://edn.embarcadero.com/en/article/37092

In fact, AFAIK, dbExpress driver for SQL Server which comes with Delphi2007/2009 calls CoInitialize(Ex)/CoUninitialize automatically, however, it seems that driver of Delphi 2010 does not call the COM APIs, now.
So, please try to call the APIs under worker thread context.

Tomohiro Takahashi at 1/18/2010 3:55:09 AM -
dbExpress drivers for MS SQL Server(dbxmss.dll, dbxmss9.dll) of Delphi 2010 do NOT call CoInitialize(Ex) API before making a connection.
On the other hand, drivers of Delphi 2007, 2009 do call CoInitialize API with its default parameter before making a connection.
But, generally speaking, user application which uses OLE/COM layer needs to call CoInitialize(Ex) explicitly with its proper parameters.

John-Arne Gangås at 1/9/2010 3:46:15 PM -
I use MS SQL Server 2005 and Delphi 2010


I have created an sample project illustrating how the TADOCOnnection affect the project.
But it sems like I don't have access to update the QC report,    (Even though I created it)
http://qc.embarcadero.com/wc/qcmain.aspx?d=80811

adoconnection.active= true   --> works fine
adeconnection.active=false   --> CoInitialize error
Remove the adoconnection component   --> Driver could not be properly initialized. Client library may be missing, not installed properly, or of the wrong version

Tomohiro Takahashi at 1/9/2010 5:17:16 PM -
> But it sems like I don't have access to update the QC report,    (Even though I created it)
Could you please use Windows Native QC client to update your report and attach a sample project(as a .zip file)?
The standalone client comes with Delphi.

John-Arne Gangås at 1/11/2010 11:09:29 PM -
Thanks you, I did not know about this client.
I have attached an testproject. Unzip the project. It also contains an test database for sql server 2005.

Tomohiro Takahashi at 1/12/2010 7:16:53 PM -
I can not build your projects, because these are quite complicated and using some third-party components.
Please attach the SIMPLEST sample projects to reproduce your issue more easily.

So, first of all, please try to call CoInitialize(Ex) API before connecting to SQL Server via TSQLConnection.

John-Arne Gangås at 1/13/2010 12:14:51 AM -
Unfortunately, calling CoInitialize did not help.

I had been using Dev Express's grid. I have now replaced it with the TDBGrid.
I have now added  an testproject.
It is as simple as I can make it. The datasnap server exposes an table.
The client connect and retrives this table.
You need to attach the testDB.mdf database file to an sql server instance



adoconnection.active= true   --> works fine
adeconnection.active=false   --> CoInitialize error
Remove the adoconnection component   --> Driver could not be properly initialized. Client library may be missing, not installed properly, or of the wrong version

Tomohiro Takahashi at 1/17/2010 9:14:59 PM -
Hi,
Please follow the Steps.
1. Open server project and open 'TServerMethods1.pas'
    and remove dummy TADOConnection component from it.
2. In the server project, make sure Connected property of TSQLConnection is set to False at Design Time via Object Inspector(*).
    (*Turning off Connected property explicitly is important)
3. Add OnCreate event handler for TServerMethods1 class and write code as below.
---------------
procedure TServerMethods1.DSServerModuleCreate(Sender: TObject);
begin
  CoInitializeEx(nil, COINIT_MULTITHREADED);
  SQLConnection1.Connected := True;
end;
---------------
4. Build server project and run it.
5. start client application and connect to it.

Server Response from: ETNACODE01