hi
i need cod in create calc field runtime by msquery.
thnkx
how to create calc field runtime by msquery
-
- Posts: 5
- Joined: Thu 26 Nov 2009 14:28
- Location: iran
- Contact:
You can use the following code:
Code: Select all
var
CalcField: TField;
begin
CalcField := TIntegerField.Create(MSQuery);
CalcField.Calculated := True;
CalcField.FieldName := CalcFieldName;
CalcField.DataSet := MSQuery;
end;
-
- Posts: 5
- Joined: Thu 26 Nov 2009 14:28
- Location: iran
- Contact:
To create the fields of your SQL query in run-time, use the following code:
After that add calculated field and then open the query.
Code: Select all
MSQuery.FieldDefs.Update;
for i := 0 to MSQuery.FieldDefList.Count - 1 do
with MSQuery.FieldDefList[i] do
if (DataType ftUnknown) and not (DataType in ObjectFieldTypes) then
CreateField(MSQuery, nil, MSQuery.FieldDefList.Strings[i]);