Subject | Basic question about inserting using TIBOTable |
---|---|
Author | jacobhavkrog |
Post date | 2011-02-09T17:18:28Z |
Hi - here is another basic question from my migration from BDE to Firebird using IBO
In my app I often use this function to get a table:
function NewTable(const ATableName: string): TIBOTable;
begin
Result := TIBOTable.Create(nil);
with Result do begin
Name := ATableName + 'Table' + IntToStr(n); Inc(n);
DatabaseName := DsaDbName;
TableName := ATableName
end
end;
like in this example:
with NewTable('CenSub') do try
Open;
Insert;
FieldByName('GroupNo').AsInteger := 1;
FieldByName('SubSubNo').AsInteger := 2;
Post;
Close
finally
Free
end;
My problem is that I get an error saying, that the primary key field of the CenSub table must have a value. The field is an autoinc field, so I'd expect it to get a value automatically.
Whats the right way to do this in the IBO world?
Thanks,
Jacob :-)
In my app I often use this function to get a table:
function NewTable(const ATableName: string): TIBOTable;
begin
Result := TIBOTable.Create(nil);
with Result do begin
Name := ATableName + 'Table' + IntToStr(n); Inc(n);
DatabaseName := DsaDbName;
TableName := ATableName
end
end;
like in this example:
with NewTable('CenSub') do try
Open;
Insert;
FieldByName('GroupNo').AsInteger := 1;
FieldByName('SubSubNo').AsInteger := 2;
Post;
Close
finally
Free
end;
My problem is that I get an error saying, that the primary key field of the CenSub table must have a value. The field is an autoinc field, so I'd expect it to get a value automatically.
Whats the right way to do this in the IBO world?
Thanks,
Jacob :-)