Hi everyone,
getting more understanding of Delphi (5) and InterBase (OE), but still searching the paths - this will be a bit longer one
I have a main form with DBGrid showing (potentially subset) of an InterBase view (4 tables master/detail chain, well normalized); access is done via IBX. On double-click or select+button in the grid I store the main table key of the selected in public variable Person_ID of another form:
That form is a detail editor for people. On FormCreate I create the connection to Interbase:
The field name of the DBEdits I set at design time, on FormShow of the detail editor I retrieve the record and the fields get nicely populated:
First problem now: the fields have trailing spaces due to length on the database - can that be trimmed easily?
More important: I cannot edit any of the fields, they all reject any typing - someone knows what that is caused by? This one is really confusing me.
And a final one, just to check if I got the Delphi documentation right and do not try something that'll never work: the IBUpdateSQL component I have to create for each of the tables in the database view, so I can write back? Or is it also possible some way to use IBSQL and create adhoc update statements? With this mini application performance isn't an issue, just around 3000 people on the master table.
Thanks!
Matthias
getting more understanding of Delphi (5) and InterBase (OE), but still searching the paths - this will be a bit longer one
I have a main form with DBGrid showing (potentially subset) of an InterBase view (4 tables master/detail chain, well normalized); access is done via IBX. On double-click or select+button in the grid I store the main table key of the selected in public variable Person_ID of another form:
Code:
//-- make primary key available
FORM_EditorPerson.Person_ID := IBQuery.Fields.FieldByName('PERSON_ID').AsInteger;
//-- call detail editor
if FORM_EditorPerson.ShowModal = mrOK then begin
..
That form is a detail editor for people. On FormCreate I create the connection to Interbase:
Code:
//-- activate DB
IBDatabase := TIBDatabase.Create (nil);
with IBDatabase do begin
DatabaseName := AboDatabasePath; //-- from registry
SQLDialect := 3; //-- IB SQL-3
LoginPrompt := false; //-- auto-login
Params.Add ('user_name=...');
Params.Add ('password=...');
Connected := true;
end;
IBDataSet := TIBDataSet.Create (nil);
with IBDataSet do begin
Database := IBDatabase;
CachedUpdates := true; //-- wanna write
end;
IBTransaction := TIBTransaction.Create (nil);
with IBTransaction do begin
DefaultDatabase := IBDatabase;
Active := true;
end;
IBQuery := TIBQuery.Create (nil);
with IBQuery do begin
Database := IBDatabase;
Transaction := IBTransaction;
end;
DataSource := TDataSource.Create (nil);
DataSource.DataSet := IBQuery;
//-- connect VCL components to DB
DBEdit_Lastname.DataSource := DataSource;
..
The field name of the DBEdits I set at design time, on FormShow of the detail editor I retrieve the record and the fields get nicely populated:
Code:
IBQuery.SQL.Text := 'select * from V_PERSON_ADDR '
+ 'where PERSON_ID = ' + inttostr(PERSON_ID);
IBQuery.Active := true;
First problem now: the fields have trailing spaces due to length on the database - can that be trimmed easily?
More important: I cannot edit any of the fields, they all reject any typing - someone knows what that is caused by? This one is really confusing me.
And a final one, just to check if I got the Delphi documentation right and do not try something that'll never work: the IBUpdateSQL component I have to create for each of the tables in the database view, so I can write back? Or is it also possible some way to use IBSQL and create adhoc update statements? With this mini application performance isn't an issue, just around 3000 people on the master table.
Thanks!
Matthias