0

在此处输入图像描述

我在水晶报表中显示连接表中的数据内容时遇到问题,我的 sql 查询很好,它显示了我自己的数据,但是当我填充水晶报表数据源并显示水晶重复重复和更多数据时,我的代码是:

 Dim rep As CrystalReport1 = New CrystalReport1()
Dim objcon = New SqlConnection("data source=(local);initial catalog=hesabres;user id='sa';password='Maysam7026'")
Dim objcom = New SqlCommand
Dim objdata As New DataTable
Dim objdr As SqlDataReader
objcom.CommandText = " SELECT customer.customer_name, customer.customer_tel, orders.order_stuff_name, orders.order_number" & _ " FROM   hesabres.dbo.orders orders inner JOIN hesabres.dbo.customer customer ON orders.order_customer_id=customer.customer_id"


objcom.Connection = objcon
objcon.Open()
objdr = objcom.ExecuteReader
objdata.Load(objdr)
rep.SetDataSource(objdata)
CrystalReportViewer1.ReportSource = rep

事实上,可能买了一把椅子和一个球,而贾汉买了一个球!

4

1 回答 1

0

Crystal 报表本身不显示任何数据。

如果您的数据库查询结果很好,那么他们的代码就是他们的东西。

我建议请详细检查您的代码。

在 select 语句中应用 distinct 关键字,如下所示,然后检查它

    SELECT Distinct customer.customer_name, customer.customer_tel, 
orders.order_stuff_name, orders.order_number" & _ " 
FROM   hesabres.dbo.orders orders 
inner JOIN hesabres.dbo.customer customer 
ON orders.order_customer_id=customer.customer_id
于 2012-05-22T12:44:53.977 回答