[fpc-pascal] Using TSdfDataset

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Sat Sep 6 04:16:38 CEST 2008


Hello,

I am trying to use TSdfDataset, but without success. I get the following crash:

Breakpoint 1, 0x0000f386 in fpc_raiseexception ()
(gdb) bt
#0  0x0000f386 in fpc_raiseexception ()
#1  0x001e0009 in DB_TFIELD_$__GETASVARIANT$$VARIANT ()
#2  0x0002dd4d in TMAINFORM__CREATE (AOWNER=0x134d010, vmt=0x1,
this=0x1363900) at app.pas:204
#3  0x0002b563 in TAPPLICATION__CREATEFORM (INSTANCECLASS=<incomplete
type>, REFERENCE=void, this=0x134d010) at application.inc:1749
#4  0x00001da4 in PASCALMAIN () at turbocircuit.dpr:47
#5  0x0001bb15 in SYSTEM_FPC_SYSTEMMAIN$LONGINT$PPCHAR$PPCHAR ()
#6  0x00001d42 in _start ()
#7  0x00001c69 in start ()

For SQLite I just activate the dataset and everything works. For
TSdfDataset it didn't work, so I tryed manually setting the fields in
my dataset, but it still doesn't work, and the crash appears in a
rather strange place, as the main form has no database code. It's in a
units initalization code instead:

constructor TComponentsDatabase.Create;
var
  MyField: TField;
begin
  inherited Create;

  FDataset := TSdfDataset.Create(nil);
  FDataset.FileName := vConfigurations.ComponentsDBFile;
//  FDataset.TableName := STR_DB_COMPONENTS_TABLE;
//  FDataset.PrimaryKey := STR_DB_COMPONENTS_ID;

  MyField := TField.Create(nil);
  MyField.FieldName := 'ID';
  MyField.SetFieldType(ftInteger);
  FDataset.Fields.Add(MyField);

  MyField := TField.Create(nil);
  MyField.FieldName := 'NAMEEN';
  MyField.SetFieldType(ftString);
  FDataset.Fields.Add(MyField);

  MyField := TField.Create(nil);
  MyField.FieldName := 'NAMEPT';
  MyField.SetFieldType(ftString);
  FDataset.Fields.Add(MyField);

  MyField := TField.Create(nil);
  MyField.FieldName := 'HEIGHT';
  MyField.SetFieldType(ftString);
  FDataset.Fields.Add(MyField);

  MyField := TField.Create(nil);
  MyField.FieldName := 'WIDTH';
  MyField.SetFieldType(ftInteger);
  FDataset.Fields.Add(MyField);

  MyField := TField.Create(nil);
  MyField.FieldName := 'PINS';
  MyField.SetFieldType(ftInteger);
  FDataset.Fields.Add(MyField);

  MyField := TField.Create(nil);
  MyField.FieldName := 'DRAWINGCODE';
  MyField.SetFieldType(ftMemo);
  FDataset.Fields.Add(MyField);

  FDataset.Active := True;
end;

Any ideas how to get TSdfDataset working?

thanks,
-- 
Felipe Monteiro de Carvalho



More information about the fpc-pascal mailing list