Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tquery SQL question

Status
Not open for further replies.

luistsousa

Technical User
May 12, 2003
66
PT
Hello

I have a very simple question to make. With the code below i create a new field in a table. However, I want create a new field with a variable name. So, Who I insert a variable "new_field" in tquery sql?

Many thanks

Query1->Close();
Query1->SQL->Clear();
Query1->SQL->Add("ALTER TABLE table_name, ADD new_field CHAR(25)");
Query1->ExecSQL();
 
Hi

The problem is that parameters cannot be used to pass values for metadata object names (table and column names).

It must exist other solution, I hop.

Regards
 
I forgoted to said that I use a mysql database and when i run the code below appear a error message with "general sql error [Mysql].....:

Query1->SQL->Add("ALTER TABLE alter_exp, ADD :name CHAR(25)");
Query1->Params->ParamByName("name")->AsString = "Deg";
Query1->ExecSQL();

appear a error message with "general sql error [Mysql].....
 
I used the format function and this resolved the problem.

REgards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top