How to dynamic add the field in TMSQuery
How to dynamic add the field in TMSQuery
I have a problem in TMSQuery. How to add the field in TMSQuery? I don't want to pre-add the field in the TMSQuery. And my SQL is dynamic script. So I need to re-define the field in fielddef
			
									
									
						- 
				AndreyZ
 
Re: How to dynamic add the field in TMSQuery
You can use the following code:
			
									
									
						Code: Select all
MSQuery1.SQL.Text := 'select * from tablename';
MSQuery1.FieldDefs.Add('fieldname', ftInteger);
MSQuery1.FieldDefs[0].CreateField(MSQuery1);
MSQuery1.Open;Re: How to dynamic add the field in TMSQuery
Sorry that I got the error message when using the following code. The error message is "E2034 Too Many actual parameters". Before I also use the following code for testing and got the same error. Any idea?
f.FieldName := msqry_dispfield.FieldByName('map_table_field').FieldName;
for i := low(FieldTypeStr) to high(FieldTypeStr) do
if msqry_dispfield.FieldByName('map_del_attrib').AsString = FieldTypeStr then
begin
msqry_result.Fields.Add(f, TFieldType(i));
msqry_result.FieldDefs[count].CreateField(msqry_result);
break;
end;
			
									
									
						f.FieldName := msqry_dispfield.FieldByName('map_table_field').FieldName;
for i := low(FieldTypeStr) to high(FieldTypeStr) do
if msqry_dispfield.FieldByName('map_del_attrib').AsString = FieldTypeStr then
begin
msqry_result.Fields.Add(f, TFieldType(i));
msqry_result.FieldDefs[count].CreateField(msqry_result);
break;
end;
- 
				AndreyZ
 
Re: How to dynamic add the field in TMSQuery
Please try creating a small sample to demonstrate the problem and send it to andreyz*devart*com . Also please specify the following:
- the exact version of SDAC. You can learn it from the About sheet of TMSConnection Editor;
- the exact version of your IDE.
			
									
									
						- the exact version of SDAC. You can learn it from the About sheet of TMSConnection Editor;
- the exact version of your IDE.