Hi!
>When I assign a string to a parameter with AsString option, it puts me
>the character ' before and after my string that is to be inserted, and
>the Mysql interpreter ignores that string resulting a bad dataset
>returned.
>How can I avoid these ' characters?
>
>E.g. SELECT * FROM table ORDER BY :prm
>which gives me
>SELECT * FROM table ORDER BY 'realprm'
The only way you can avoid quotes is to prepare your select statement on
the fly just before executing the query, something like the follows:
const
qryOrderByMask='SELECT * FROM %s ORDER BY %s';
....
procedure RerformQuery(const TabelName,OrderList:string);
var
Buf:string;
begin
//Here we prepare select statement with needed table name and needed
ORDER BY clause
Buf:=Format(qryOrderByMask,[TableName,OrderList]);
//Now prepare query object and execute it
with MyQuery do
begin
//Drop current query statement, stored in a query object
if Prepared then
UnPrepare;
//Assign new select statement
SQL:=Buf;
//And finally prepare and execute query object
Prepare;
Open;
end;
end;
Using this technique, you can dynamically alter any part of SQL statement.
Best regards, Pavel Evarestov
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/i7folB/TM
--------------------------------------------------------------------~->
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/