crystal report和sql命令

时间:2012-05-22 08:14:59

标签: sql vb.net crystal-reports

enter image description here

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

 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
实际上可能买了一把椅子和球,而jahan买了一个球!

1 个答案:

答案 0 :(得分: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