Hola Chenech.
Como pasas el SQL resultante del DBExpress a un TClientDataSet?.. me podrias indicar?..
Yo estoy usando este formato en mi programa.
Código Delphi
[-]
DataSource --> ClienDataSet --> DataSetProvider --> SqlDataSet --> SqlConnecction
El DataSource en su propiedad: Dataset, apunta a: ClientDataSet.
El ClientDataSet en su propiedad: ProviderName, apunta a: DataSetProvider.
El DataSetProvider, en su propiedad: DataSet, apunta a: SQLDataSet.
El SQLDataSet, en su propiedad: SQLConnection, apunta a: SQLConnection.
SQL_String, es una variable global de tipo TSQLDataSet, que se inicializa de la siguiente manera:
Código Delphi
[-]
SQL_String := TSQLDataSet.Create(nil);
SQL_String.SQLConnection := SQLConnection;
La consulta la hago de la siguiente forma:
Código Delphi
[-]
procedure TFPreparaFile.TrasDetalleVentas;
begin
sPar1Aux := Stuff(sFechaIni, SeparadorFecha, '.', 'A');
Dt1.SQLDataSet.Close;
SQL_Text := 'SELECT DetFact.Mes, DetFact.TipoDoc, DetFact.Rut, DetFact.CodAux, DetFact.Numero, ' +
'DetFact.FechaEmi, DetFact.Codigo, DetFact.Descrip, DetFact.Cantidad, ' +
'DetFact.TotalLinDe, DetFact.Vendedor, Vendedores.Nombre ' +
'FROM DetFact ' +
'LEFT JOIN Vendedores ' +
'ON Vendedores.Codigo=DetFact.Vendedor ' +
'WHERE DetFact.FechaEmi>=' + QuotedStr( sPar1Aux ) + ' ' +
'ORDER BY Mes ASC ' + ';';
SQL_String := Dt1.SQLDataSet;
SQL_String.Close;
SQL_String.CommandText := SQL_Text;
SQL_String.Open;
end;
y, luego el reporte. Que tiene un titulo, y solo 3 bandas para el detalle.
Esta es la estructura basica de mi reporte:
Código Delphi
[-]
---------------------------------------------------------------------------------------
Fecha TipoDoc Numero Codigo Nombre Cantidad Costo Total
---------------------------------------------------------------------------------------
================================================
QRGDetMes - TQRGroup
Expression: Mes
FooterBand: QrSubTotalMes
LinkBand: QrBandDet
---------------------------------------------------------------------------------
=================================================================================
QrBandDet - TQrBand
BandType: rbDetail
--------------------------------------------------------------------------------
================================================================================
QrSubTotalMes - TQrBand
BandType: rbGroupFooter
--------------------------------------------------------------------------------
Funciona bien hasta que tiene que hacer el corte para subtotalizar por mes, y se cae, con el mensaje: "Operation not allowed on a unidirectional dataset".
Código Delphi
[-]
procedure TFQrDetDocVta.QRSubTotalMesBeforePrint(
Sender: TQRCustomBand; var PrintBand: Boolean); <------- Cuando entra aqui para subtotalizar por mes, se cae, y presenta el mensaje: "Operation not allowed on a unidirectional dataset".
begin
QrTotal.Caption := FloatToStr(itTotal);
itTotal := 0;
end;
El Reporte lo simplifique para que se entienda mejor.
Agradeceria si me pudieran ayudar.
Gracias.
Saludos.
Jose Miguel B.