1.在窗体上加:Query1,datasource1,dbgrid1;
2.Query1: TQuery
    Active = True
    OnCalcFields = Query1CalcFields
    DatabaseName = 'DBDEMOS'
    SQL.Strings = (
        'SELECT OrderNo, CustNo, SaleDate, ShipDate, EmpNo, ShipToContact' +
        ', ShipToAddr1, ShipToAddr2, ShipToCity, ShipToState, ShipToZip, ' +
        'ShipToCountry, ShipToPhone, ShipVIA, PO, Terms, PaymentMethod, I' +
        'temsTotal, TaxRate, Freight, AmountPaid'
      'FROM "orders.db" Orders')
3.其他控件请自行连接好。
4.procedure TForm1.Query1CalcFields(DataSet: TDataSet);
begin
Query1.FieldByName('test').asstring:=Query1.FieldByName('OrderNo').asstring+' '+Query1.FieldByName('CustNo').asstring;
end;

解决方案 »

  1.   

    掉了几部。 1.在窗体上加:Query1,datasource1,dbgrid1;
    2.Query1: TQuery
        Active = True
        OnCalcFields = Query1CalcFields
        DatabaseName = 'DBDEMOS'
        SQL.Strings = (
            'SELECT OrderNo, CustNo, SaleDate, ShipDate, EmpNo, ShipToContact' +
            ', ShipToAddr1, ShipToAddr2, ShipToCity, ShipToState, ShipToZip, ' +
            'ShipToCountry, ShipToPhone, ShipVIA, PO, Terms, PaymentMethod, I' +
            'temsTotal, TaxRate, Freight, AmountPaid'
          'FROM "orders.db" Orders')
    3.其他控件请自行连接好。
    4.双击Query1,在字段编辑器里加入所有的字段。
    5.右击字段编辑器,选择“new field...”,
      Name : test  component : 自动生成 
      Type : String  size :30
     
      Field type: CalCulated
    6.单击ok。
    7.
    procedure TForm1.Query1CalcFields(DataSet: TDataSet);
    begin
    Query1.FieldByName('test').asstring:=Query1.FieldByName('OrderNo').asstring+' '+Query1.FieldByName('CustNo').asstring;
    end;