Hi!
Whether developers can to give instruction how to see default values in Tdbgrid after the operation of Insert, but to the operation of Post. I.e. I want to offer to the user to enter already the partly filled record in a table?
Default values after Insert but before Post?
Moderators: gto, EgonHugeist
I have partialy solved this problem by following method
Add ROQuery for select default falues and realize next procedure which called in AfterInsert event:
Code: Select all
procedure TForm1.FillDefaultValues(ds: TDataSet);
var
strSQLDefValues: String;
i: Integer;
DefValue: String;
begin
if not (ds is TZAbstractRODataset) then exit;
if ds.State <> dsInsert then exit;
qrDefValues.Close;
strSQLDefValues := '';
for i := 1 to TZAbstractRODataset(ds).DbcResultSet.GetMetadata.GetColumnCount do
begin
if TZAbstractRODataset(ds).DbcResultSet.GetMetadata.HasDefaultValue(i) then
DefValue := TZAbstractRODataset(ds).DbcResultSet.GetMetadata.GetDefaultValue(i)
else
DefValue := '''''';
if strSQLDefValues <> '' then
strSQLDefValues := strSQLDefValues + ',' + DefValue
else
strSQLDefValues := DefValue;
end;
strSQLDefValues := 'select ' + strSQLDefValues;
try
qrDefValues.SQL.Text := strSQLDefValues;
qrDefValues.Open;
for i := 1 to TZAbstractRODataset(ds).DbcResultSet.GetMetadata.GetColumnCount do
begin
if TZAbstractRODataset(ds).DbcResultSet.GetMetadata.HasDefaultValue(i) then
ds.Fields[i-1].AsVariant := qrDefValues.Fields[i-1].AsVariant;
end;
except
on E: Exception do
begin
MessageDlg('Unable to set default values:' + #13#10 +
E.Message, mtError, [mbOk], 0);
end;
end;
end;
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
DestinyR,
The developers are gone since long. The maintainer(s?) don't know a solution working out of the box.
When you want to show the database defaults you might be able to find them in the metadata structures zeoslib uses internally. Not sure if there's a way to acces them through the layered zeoslib structure, however.
In zeoslib 7 there's also a new feature 'support for DefaultExpression TField property' introduced by SVN rev 517
Mark
The developers are gone since long. The maintainer(s?) don't know a solution working out of the box.
When you want to show the database defaults you might be able to find them in the metadata structures zeoslib uses internally. Not sure if there's a way to acces them through the layered zeoslib structure, however.
In zeoslib 7 there's also a new feature 'support for DefaultExpression TField property' introduced by SVN rev 517
Mark