Could the ParamByName function be used for column and table?
Posted: 02.01.2014, 08:42
Hello,
sorry for my poor english . I am using C++ builder 6.0+ZEOSDBO-6.6.6-stable+mysql 5.0 and not familiar with zeosdbo, when i just use ParamByName function in sql for WHERE clause just like:
FMain->ZQuery1->SQL->Add("select slot from board where eqpid=:id");
FMain->ZQuery1->ParamByName("id")->AsInteger=1;
FMain->ZQuery1->Open();
That works fine.
But when I try to use ParamByName function for column and table name, it returned error. The code is below:
FMain->ZQuery1->SQL->Add("select :col from :tab where eqpid=:id");
FMain->ZQuery1->ParamByName("col")->AsString="slot;
FMain->ZQuery1->ParamByName("tab")->AsString="board";
FMain->ZQuery1->ParamByName("id")->AsInteger=1;
FMain->ZQuery1->Open();
it will return error:
SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''board' where eqpid=1' at line 1.
The sql I expected should be "select slot from board where eqpid=1", but the real sql seems not like that. Could someone help me?
Any replies will be appreciated.
sorry for my poor english . I am using C++ builder 6.0+ZEOSDBO-6.6.6-stable+mysql 5.0 and not familiar with zeosdbo, when i just use ParamByName function in sql for WHERE clause just like:
FMain->ZQuery1->SQL->Add("select slot from board where eqpid=:id");
FMain->ZQuery1->ParamByName("id")->AsInteger=1;
FMain->ZQuery1->Open();
That works fine.
But when I try to use ParamByName function for column and table name, it returned error. The code is below:
FMain->ZQuery1->SQL->Add("select :col from :tab where eqpid=:id");
FMain->ZQuery1->ParamByName("col")->AsString="slot;
FMain->ZQuery1->ParamByName("tab")->AsString="board";
FMain->ZQuery1->ParamByName("id")->AsInteger=1;
FMain->ZQuery1->Open();
it will return error:
SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''board' where eqpid=1' at line 1.
The sql I expected should be "select slot from board where eqpid=1", but the real sql seems not like that. Could someone help me?
Any replies will be appreciated.