[fpc-pascal] Assigning value to ftVariant datatype & varbytes - still stuck
Reinier Olislagers
reinierolislagers at gmail.com
Sun Aug 7 18:06:40 CEST 2011
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.
Thanks,
Reinier
More information about the fpc-pascal
mailing list