Dynamic field problem in VirtualTable
Re: Dynamic field problem in VirtualTable
Hi, the error is coming from field creating. And can TVirtualtable handle Unicode?
			
									
									
						Re: Dynamic field problem in VirtualTable
I fixed the problem. But I need to hardcode the fieldtype that can't use dynamic define.
			
									
									
						Re: Dynamic field problem in VirtualTable
Hello,
The "Invalid field size" error occurs on incorrect field length, for example:
Please provide an example of creating your field
			
									
									
						The "Invalid field size" error occurs on incorrect field length, for example:
Code: Select all
VirtualTable1.AddField('test', ftWideString, -1);Re: Dynamic field problem in VirtualTable
I use the following code to solve the problem
if map_setting.FieldByName('map_del_attrib').AsString = 'ftWideString' then
poreport_buffer.AddField(map_setting.FieldByName('map_table_field').Value, ftWideString , map_setting.FieldByName('map_field_length').Value)
else
poreport_buffer.AddField(map_setting.FieldByName('map_table_field').Value, TFieldType(i) ,map_setting.FieldByName('map_field_length').Value);
			
									
									
						if map_setting.FieldByName('map_del_attrib').AsString = 'ftWideString' then
poreport_buffer.AddField(map_setting.FieldByName('map_table_field').Value, ftWideString , map_setting.FieldByName('map_field_length').Value)
else
poreport_buffer.AddField(map_setting.FieldByName('map_table_field').Value, TFieldType(i) ,map_setting.FieldByName('map_field_length').Value);
Re: Dynamic field problem in VirtualTable
Hello,
If, when adding a ftWideString field, you even use TFieldType(i) instead of explicit type specifying, such error doesn't occur. Please make sure that TFieldType(i) returns the correct ftWideString type.
			
									
									
						If, when adding a ftWideString field, you even use TFieldType(i) instead of explicit type specifying, such error doesn't occur. Please make sure that TFieldType(i) returns the correct ftWideString type.
Re: Dynamic field problem in VirtualTable
Thanks for your remind. But I already define ftWideString into array. It also got the error message. So I post my question in here.
const
FieldTypeStr: array [0..13] of string = ('ftUnknown', 'ftString', 'ftSmallint', 'ftInteger', 'ftWord',
'ftBoolean', 'ftFloat', 'ftCurrency', 'ftBCD', 'ftDate', 'ftTime', 'ftDateTime', 'ftMemo', 'ftWideString');
			
									
									
						const
FieldTypeStr: array [0..13] of string = ('ftUnknown', 'ftString', 'ftSmallint', 'ftInteger', 'ftWord',
'ftBoolean', 'ftFloat', 'ftCurrency', 'ftBCD', 'ftDate', 'ftTime', 'ftDateTime', 'ftMemo', 'ftWideString');
Re: Dynamic field problem in VirtualTable
Hello,
If you are using the code I provided earlier, in addition to ftWideString in the FieldTypeStr array, you should add the other types that are in TFieldType (described in the Data.DB module) before the ftWideString type.
And in your case, on the map_setting.FieldByName('map_del_attrib') = ftWideString field value,the loop variable "I" will be 14, in this case, TFieldType(14) will return the ftAutoInc type, that causes the error.
			
									
									
						If you are using the code I provided earlier, in addition to ftWideString in the FieldTypeStr array, you should add the other types that are in TFieldType (described in the Data.DB module) before the ftWideString type.
And in your case, on the map_setting.FieldByName('map_del_attrib') = ftWideString field value,the loop variable "I" will be 14, in this case, TFieldType(14) will return the ftAutoInc type, that causes the error.
Re: Dynamic field problem in VirtualTable
Yup. I'm using your earlier code. It should be 13 when I check the For loop "high(FieldTypeStr)". So I don't understand why you said "I" will return 14.
			
									
									
						Re: Dynamic field problem in VirtualTable
Hello,
Yes. the loop variable will be really equal to 13, and not to 14. But independently on this, when attempting to retrieve the type by this index from TFieldType, you will retrieve an incorrect type, since in TFieldType the ftWideString type has the index 24. You should edit your constant array according to the TFieldType description in the Data.DB module:
			
									
									
						Yes. the loop variable will be really equal to 13, and not to 14. But independently on this, when attempting to retrieve the type by this index from TFieldType, you will retrieve an incorrect type, since in TFieldType the ftWideString type has the index 24. You should edit your constant array according to the TFieldType description in the Data.DB module:
Code: Select all
   TFieldType = (ftUnknown, ftString, ftSmallint, ftInteger, ftWord, // 0..4
    ftBoolean, ftFloat, ftCurrency, ftBCD, ftDate, ftTime, ftDateTime, // 5..11
    ftBytes, ftVarBytes, ftAutoInc, ftBlob, ftMemo, ftGraphic, ftFmtMemo, // 12..18
    ftParadoxOle, ftDBaseOle, ftTypedBinary, ftCursor, ftFixedChar, ftWideString, // 19..24
    ftLargeint, ftADT, ftArray, ftReference, ftDataSet, ftOraBlob, ftOraClob, // 25..31
    ftVariant, ftInterface, ftIDispatch, ftGuid, ftTimeStamp, ftFMTBcd, // 32..37
    ftFixedWideChar, ftWideMemo, ftOraTimeStamp, ftOraInterval, // 38..41
    ftLongWord, ftShortint, ftByte, ftExtended, ftConnection, ftParams, ftStream, //42..48
    ftTimeStampOffset, ftObject, ftSingle); //49..51