Params not working for SQL 2005 Compact

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
tanong1957
Posts: 4
Joined: Thu 16 Aug 2007 05:51

Params not working for SQL 2005 Compact

Post by tanong1957 » Thu 16 Aug 2007 06:08

I'm using SDAC 4.10's TMSQuery
My code is like ->

CLOSE;
SQL.TEXT := 'SELECT * FROM CUSTOMERS'+
' WHERE ACCTNO=:ACCTNO';
PARAMS[0].VALUE := 'ABCD';
OPEN;

It only works on SQL 2005/SQL 2005 Express.
But not on SQL 2005 COMPACT. It shows error:
REQUESTED CONVERSION NOT SUPPORTED...

Please guide me how to correct it.

tanong1957
Posts: 4
Joined: Thu 16 Aug 2007 05:51

Problem Solved.

Post by tanong1957 » Thu 16 Aug 2007 11:47

I finally found a way.
Just set the param's datatype as variant ->

SQL.TEXT := 'SELECT * FROM CUSTOMERS'+
' WHERE ACCTNO=?';
PARAMS[0].DATATYPE := ftVARIANT;

...

CLOSE;
PARAMS[0].VALUE := 'ABCD';
OPEN;

It works great on both SQL Server and SQL Server Compact.
My app is totally scalable now. :D

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 20 Aug 2007 13:08

This is an acceptable solution, but we recommend using exact data types like ftInteger, ftString instead of ftVariant.

Post Reply