Board index » delphi » MySQL ODBC 3.51 and passing a date as parameter to a query

MySQL ODBC 3.51 and passing a date as parameter to a query

MySQL ODBC 3.51 and passing a date as parameter to a query

Hi!

I'm working ond Delphi 6 and BDE 5.2 to access a MySQL-Server via
MySQL ODBC 3.51. Whenever I need to set a parameter of type date
to a query (see code below), I get an EDBEngineError "Operation nicht
anwendbar". I tried to trace the cause of this exception and found,
that it is raised by DbiQSetParams() called in SetQueryParams().
DbiQSetParams() returns an error number 10756.
I've set all date formats in the system settings, bde settings and
DATEFORMAT-variable to the correct format (yyyy-mm-dd).
What else can I do to find and solve this problem? Any ideas?

bye,
  Tobias

qry := TQuery.Create(nil);
qry.DatabaseName := 'TEST';
qry.SQL.Add('INSERT INTO test_tbl (my_date) VALUES (:param1)');
qry.Params[0].AsDate := Date;
try
  qry.ExecSQL; //Exception gets raised here
finally
  qry.Free;
end;

PS: Setting the date as '2003-01-01' in the SQL-Statement works perfectly,
but I need to use parameters in the UpdateSQL-component!

 

Re:MySQL ODBC 3.51 and passing a date as parameter to a query


Quote
Tobias (tobias.gr...@cas-soft.de) wrote:

: I'm working ond Delphi 6 and BDE 5.2 to access a MySQL-Server via
: MySQL ODBC 3.51. Whenever I need to set a parameter of type date
: to a query (see code below), I get an EDBEngineError "Operation nicht
: anwendbar". I tried to trace the cause of this exception and found,
: that it is raised by DbiQSetParams() called in SetQueryParams().
: DbiQSetParams() returns an error number 10756.
: I've set all date formats in the system settings, bde settings and
: DATEFORMAT-variable to the correct format (yyyy-mm-dd).
: What else can I do to find and solve this problem? Any ideas?

I have no personal experience with mySQL, but since the BDE is
deprecated and will not see future development, it may be time
to try another method of data access. One free solution to look
at is http://www.zeoslib.org/ Also see an article on the "9 top
ways" to access mySQL at http://delphi.about.com/
--
Rick Carter
carte...@email.uc.edu   Rick.Car...@ParadoxCommunity.com
Chair,   Paradox/Delphi SIG,   Cincinnati PC Users Group

Re:MySQL ODBC 3.51 and passing a date as parameter to a query


Hi Richard,

Quote
> I have no personal experience with mySQL, but since the BDE is
> deprecated and will not see future development, it may be time
> to try another method of data access.

I tried dbExpress, but couldn't get it to work with MySQL, so I just
started using the BDE.

Quote
> One free solution to look
> at is http://www.zeoslib.org/ Also see an article on the "9 top

Thanks for this hint!
I already considered this some months ago, but because the components
haven't
been updated for quit a while at this time, I prefered to stay away
from it.
But now as you mention it, it seems there have been some updates in
the last weeks. Maybe I should give it a try.

BTW: The problem with the query parameters seems to be caused by the
ODBC driver. With the 2.xx instead of the 3.xx MySQL ODBC driver,
there
are no problems.

bye,

Tobias

Other Threads