Skip to Content
0
Former Member
Jul 27, 2016 at 07:51 AM

CR XI problem with inner join same name fields in both tables

36 Views

We have been looking for the solution of our problem in all forums and discussion but we still having the problem without finding the solution.

When we try to do a simple inner join and both tables have the same name field (for example "nombre" in our case) the crystal reports only show one of the fields, we insert in the report the field of the second table but the reports shows the information of the first table, and we don't know why.

We are working with Crystal Reports XI, and with the reference CrystalDecisions.CrystalReports.engine 13.0.2000.0

Here you guys have and example of our code.

Dim Rpt As New ReportDocument Dim Sql as String

Dim myTables As CrystalDecisions.CrystalReports.Engine.Table

Dim myConnectionInfo As New ConnectionInfo()

Dim logOnInfo As New TableLogOnInfo()

Rpt = New ReportDocument

Rpt.Load("C:\Rpt\Pruebas.rpt", CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)

For Each myTables In Rpt.Database.Tables

logOnInfo = Rpt.Database.Tables.Item(myTables.Name).LogOnInfo

myConnectionInfo = Rpt.Database.Tables.Item(myTables.Name).LogOnInfo.ConnectionInfo

myConnectionInfo.ServerName = "Servidor"

myConnectionInfo.UserID = "UserID"

myConnectionInfo.Password = "Pwd"

myConnectionInfo.DatabaseName = "BD"

Rpt.Database.Tables.Item(myTables.Name).ApplyLogOnInfo(logOnInfo)

Next myTables

Sql="select agricultor.codigo, agricultor.nombre, parcelas.nombre from agricultor inner join parcelas on agricultor.id = parcelas.idAg"

Rpt.SetSQLCommandTable(myConnectionInfo, "Informe", Sql)

CrystalReportViewer.ReportSource = Rpt