> 
> Hi list,
> 
> Free Pascal Compiler version 2.5.1 [2011/08/04] for i386
> 
> While improving my fcl-db XML export code, I'm testing with 
> ftVariant types in a bufdataset:
>   FieldDef := FTestDataset.FieldDefs.AddFieldDef;
>   FieldDef.Name := 'ftVariant';
>   FieldDef.DataType := ftVariant;
> 
> This works:
>   TestString:='The answer to life, the universe, and everything';
>   FTestDataset.Append;
>   FTestDataSet.FieldByName('ftVarBytes').AsString:=TestString;
>   FTestDataSet.FieldByName('ftVarBytes').SetData(TempPChar);
>   //FTestDataSet.FieldByName('ftVariant').AsString:=TestString;
>   FTestDataset.Post;
> 
> However, I can't assign values to ftVariant, whatever 
> combination I try. The strange thing is that I get an access 
> violation when printing the fields' contents in a loop, and 
> it happens when getting the value for ftVarBytes. Would it 
> have to do with the ASCII NULL delimiter Ludo Brands reported 
> in http://bugs.freepascal.org/view.php?id=19922
> 
> This doesn't work:
>   //FTestDataSet.FieldByName('ftVarBytes').AsString:=TestString;
>   FTestDataSet.FieldByName('ftVarBytes').SetData(TempPChar);
>   FTestDataSet.FieldByName('ftVariant').AsString:=TestString;
> 
> nor this:
>   //FTestDataSet.FieldByName('ftVarBytes').AsString:=TestString;
>   //FTestDataSet.FieldByName('ftVarBytes').SetData(TempPChar);
>   FTestDataSet.FieldByName('ftVariant').AsString:=TestString;
> 
> nor this:
>   FTestDataSet.FieldByName('ftVarBytes').AsString:=TestString;
>   FTestDataSet.FieldByName('ftVarBytes').SetData(TempPChar);
>   FTestDataSet.FieldByName('ftVariant').AsString:=TestString;
> 
> How can I properly assign values to ftVarBytes and ftVariant 
> and retrieve them? I know I asked before for ftVarBytes; I 
> just use .AsString:='bla', but obviously it doesn't work.
> 

Same problem as before: TBufDataset doesn't support correctly ftVarBytes and
ftVariant and doesn't raise an SErrFieldTypeNotSupported like TMemDataset is
doing.
Look at TCustomBufDataset.GetFieldSize and you'll see that data length for
ftVarBytes and ftVariant is arbitrarely set at 10. Compare this with
TMemDataset.MDSGetBufferSize.

Ludo

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to