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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a field to a table at runtime

Status
Not open for further replies.

Ronin441

Programmer
Feb 22, 2002
128
AU
I know how to create a table at runtime by setting up FieldDefs and IndexDefs and calling CreateTable; but how can I add fields and indeces to an already existing table? -- Doug Burbidge mailto:doug@ultrazone.com
 
hi

You could build the Query in the SQL property of a TQuery at runtime(or design time) and call MyQry.ExecSQL.

lou
 
/me goes away and reads about TQuery for an hour
/me goes away and reads SQL language reference for an hour

Very cool! Problem solved in one line of code:
Code:
MyDatabase.Execute('ALTER TABLE ' + TableName + ' ADD myfield1 VARCHAR(8), ADD myfield2 VARCHAR(8);', nil, False, nil);
OK, so it took me two hours to write that one line of code, but it's still cool. -- Doug Burbidge mailto:doug@ultrazone.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top