Dictionary data table design and table field sorting
Method for reading dictionary metadata procedure setdataset (Dataset: tdataset; const table: string );
VaR
D: tadoquery;
I: integer;
Begin
If dataset = nil then exit;
If not dataset. Active then exit;
If table = ''then exit;
D: = tadoquery. Create (NiL );
Try
With d do
Begin
Connection: = ufunction. getconnection;
Close;
SQL. Clear;
SQL. Text: = 'select table, ename, cname, width, visible from dictionary '+
'Where table =: ';
Parameters. parambyname ('A'). Value: = table;
Open;
End;
If D. isempty then exit;
D. first;
While not D. EOF do
Begin
For I: = 0 to dataset. fieldcount-1 do
Begin
If dataset. Fields [I]. fieldname = D. findfield ('ename'). asstring then
Begin
Dataset. Fields [I]. displaylabel: = D. findfield ('cname'). asstring;
Dataset. Fields [I]. displaywidth: = D. findfield ('width'). asinteger;
Dataset. Fields [I]. Visible: = D. findfield ('visable'). asboolean;
Break;
End;
End;
D. Next;
End;
Finally
D. Free;
End;
End; call Example procedure tformemployee. hyvisualplugincreate (Sender: tobject );
Begin
With adoquery1 do
Begin
Connection: = ufunction. getconnection;
Close;
SQL. Clear;
SQL. Text: = 'select * from employee ';
Open;
End;
Ufunction. setdataset (adoquery1, 'Employee ');
End; slice