简体   繁体   中英

Duplicated data in crystal reports

I am trying to load data from 3 tables in a crystal report.

in each one, I have stored procedures that shows me the following data:

在此处输入图片说明

The codes are:

select distinct * from servicios where ID_Orden = @idordenrecibida

SELECT  distinct ID_orden, Consecutivo, Observaciones, Empleado, replace(convert(NVARCHAR, FechaEntrada, 103), ' ', '/') AS FechaEntrada, replace(convert(NVARCHAR, FechaSalida, 103), ' ', '/') AS FechaSalida, Recibe, PrecioFinal
FROM    OrdenesServicio
WHERE ID_Orden = @idordenrecibida

SELECT distinct * FROM equipos WHERE ID_Orden = @idordenrecibida

(the parameter sent from CR is '8' too in the next snapshots)

And I want to show the same in my report, but the report shows some duplicated results when I call these procedures from CR:

在此处输入图片说明

It shows some repeated values, unlike the real result of the procedure :S

Well, the code in the form is the following:

        OrdenReport oRep = new OrdenReport();
        ParameterField Pf = new ParameterField();
        ParameterFields Pfs = new ParameterFields();
        ParameterDiscreteValue Pdv = new ParameterDiscreteValue();
        Pf.Name = "@idordenrecibida"; //nombre del parametro
        Pdv.Value = 8;
        Pf.CurrentValues.Add(Pdv);
        Pfs.Add(Pf);
        crystalReportViewer1.ParameterFieldInfo = Pfs;
        oRep.Load(@"..\..\OrdenReport.rpt");
        crystalReportViewer1.ReportSource = oRep;

And this is the design of the form:

在此处输入图片说明

The way I followed the Wizard:

在此处输入图片说明在此处输入图片说明在此处输入图片说明在此处输入图片说明在此处输入图片说明

If I select the "no repeat" option in designer, "Equipos" shows perfectly, but "Servicios" is still showing duplicates. In fact, the total number of "Equipos" is the times that "servicios" is duplicated. I tried modifying the relationships but the duplicates are still appearing. How could I have in that report the same data than the "exec" without mistakenly repeating the same rows?? Thanks!!

EDIT:

I found that the data are showing duplicate only when I want to show the data of the two tables together, so when I delete from the designer the fields of the table servicios:

在此处输入图片说明

And then, I do control + Z, I select the other half part (which corresponds to table equipos) and I press supr. And it shows:

在此处输入图片说明

But if I want to show the two together duplicates the fields of one of the two tables. I tried moving to another section, but then only shows ONE file, not the 2 or 3 that has to show.

What can I do to show them in the same report properly??

As the picture shows, check your database fields are duplicated by _No. Use either one of the field and your problem will be solved.

在此处输入图片说明

All the data you get in Crystal Reports is based on one set of rows that is formed by joining or linking all the given tables together. The Details section represents one row. When you put leerEquipos and leerServicios in the same report they are merged into the same set of rows, like this:

|ID_Equipo|ID_Servicio|ID_Orden|
|60       |41         |8       |
|61       |41         |8       |
|60       |42         |8       |
|61       |42         |8       |
|60       |43         |8       |
|61       |43         |8       |

You have two equipos and three servicios. As they are cross joined (combined in every possible combination) the result is six rows.

If you would like to see the listing of Servicios and the listing of Equipos completely separately from each other you would need two completely separate set of rows (ie a set of two Equipo rows and a set of three Servicio rows). Usually the safest way is to do this with subreports.

If there is a connection between Servicios and Equipos (when they have the same ID_Orden) you have to ask what information do you want to see on one row: If you want one row for every Servicio then group the report by Servicio and then you can insert the count of the computers in a summary field for example. If you want two rows - one row per Equipo, then group by Equipo.

You can find a lot of instructions (and questions) on the net about duplicate rows in Crystal Reports:
Troubleshooting "Duplicate Records" in Crystal Reports
Dealing with duplicate records or “table inflation”

Try option Select Distinct Records under Database to exclude duplicate records.

Along with that I would suggest you to check the linking why it is producing duplicate records.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM