Getting the "Arguments of the wrong type ..." exception by simply assigning the query text

I downloaded and installed MySQL Connector 5.1 x64, so I can use MySQL with Delphi. I can connect to ODBC and connect from my Delphi environment and from MySQL Workbench.

But when I create my request at runtime, I get an error message:

Project AAA.exe raised the EOleException class with the message "Arguments are of the wrong type, are out of range, or are in conflict with each other." The process is stopped. Use Step or Run to continue.

My code is:

qDates := TADOQuery.Create(Component); qDates.Connection := FConnection; qDates.SQL.Text := 'select ' + ' * ' + 'from ' + ' resulttable ' + 'where ' + ' oid = :oid ' + ' and datedial >= :datebegin and datedial <= :dateend'; // <<-- Exception here 

Details:
An exception occurs right in the text destination before I can configure the settings.
If I comment on the where clause, the assignment will be fine.
This is similar to Using Parameters with ADO Query (mysql / MyConnector) , but the difference is that I assign all the text at once and I get an exception before I have a chance to configure the parameters.

The incomprehensible part is that the same code works fine on my other machine, but I can't figure out what is different.

Therefore, the question is - what could cause the above exception outside of Delphi code and MySQL server?

+7
mysql delphi
source share
1 answer

This is apparently a quirk with the MySQL ODBC provider.

If you assigned a connection after setting the SQL text, it will work. The reason you can find it here .

 qDates := TADOQuery.Create(Component); // do net yet assign TADOConnection to prevent roundtrip to ODBC provider qDates.SQL.Text := 'select ' + ' * ' + 'from ' + ' resulttable ' + 'where ' + ' oid = :oid ' + ' and datedial >= :datebegin and datedial <= :dateend'; qDates.Connection := FConnection; 

UPDATE

This QC entry explains the exact cause of this problem.

In short, the ADODB block, correct this line from the RefreshFromOleDB procedure:

  Parameter.Attributes := dwFlags and $FFFFFFF0; { Mask out Input/Output flags } 

To:

 if dwFlags and $FFFFFFF0 <= adParamSigned + adParamNullable + adParamLong then Parameter.Attributes := dwFlags and $FFFFFFF0; { Mask out Input/Output flags } 
+5
source share

All Articles