Page 1 of 1

How to create a command passing parameters

Posted: Thu 26 Oct 2017 12:30
by brace
I would like to use TMSQuery to create a parametric command.

I usually do
MSQuery1.SQL.Text := 'CREATE DATABASE ' + aMyDBName;

but if I have
CREATE DATABASE :MyDBName
and i try to do
MSQuery1.ParamByName('MyDBName').asstring := aMyDBName;
when i execute the query i have
"Wrong syntax near @P1"

how to avoid this error and use ParamByName succesfully in my context?

Thanks

Re: How to create a command passing parameters

Posted: Fri 27 Oct 2017 07:45
by Stellar
You cannot pass the database name as a parameter in this query, since this functionality is not supported by MS SQL Server and we cannot affect it. To solve this task, you can use macros. More details about macros here: https://www.devart.com/sdac/docs/index. ... macros.htm

Re: How to create a command passing parameters

Posted: Fri 27 Oct 2017 10:20
by brace
Thanks for the reply, now i got the difference between parameter and macro.