【发布时间】:2017-09-01 14:28:17
【问题描述】:
我已经在 vb.net 中编写了一个查询以显示在水晶报表中,但是一列名称 Customer.Name 在我的查询和代码的所有行中的报表中显示相同
Dim rpt As New rptSales2 'The report you created.
Dim myConnection As SqlConnection
Dim MyCommand, MyCommand1 As New SqlCommand()
Dim myDA, myDA1 As New SqlDataAdapter()
Dim myDS, myDS1 As New DataSet 'The DataSet you created.
myConnection = New SqlConnection(cs)
MyCommand.Connection = myConnection
MyCommand1.Connection = myConnection
MyCommand.CommandText = "select invoiceinfo.Inv_ID, invoiceinfo.InvoiceNo,invoiceinfo.InvoiceDate, Customer.Name, sum(InvoiceInfo.GrandTotal)-sum(invoiceinfo.prevdue) as grandtotal, sum(invoiceinfo.TotalPaid) as totalpaid,ISNULL(sum(Balance),0)-ISNULL(sum(prevdue),0) as currentdue,ISNULL(sum(prevdue),0) as prevdue,sum(invoiceinfo.Balance) as Balance from InvoiceInfo inner join Customer on InvoiceInfo.CustomerID = Customer.ID where InvoiceDate between @d1 and @d2 group by invoiceinfo.InvoiceDate,invoiceinfo.InvoiceNo,Customer.Name,InvoiceInfo.TotalPaid,invoiceinfo.Inv_ID"
MyCommand.Parameters.Add("@d1", SqlDbType.DateTime, 30, "Date").Value = dtpDateFrom.Value.Date
MyCommand.Parameters.Add("@d2", SqlDbType.DateTime, 30, "Date").Value = dtpDateTo.Value.Date
MyCommand1.CommandText = "SELECT * from Company"
MyCommand.CommandType = CommandType.Text
MyCommand1.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand
myDA1.SelectCommand = MyCommand1
myDA.Fill(myDS, "InvoiceInfo")
myDA.Fill(myDS, "Customer")
myDA1.Fill(myDS, "Company")
这里是sql查询select invoiceinfo.Inv_ID, invoiceinfo.InvoiceNo,invoiceinfo.InvoiceDate, Customer.Name, sum(InvoiceInfo.GrandTotal)-sum(invoiceinfo.prevdue) as grandtotal, sum(invoiceinfo.TotalPaid) as totalpaid,ISNULL(sum(Balance),0)-ISNULL(sum(prevdue),0) as currentdue,ISNULL(sum(prevdue),0) as prevdue,sum(invoiceinfo.Balance) as Balance from InvoiceInfo inner join Customer on InvoiceInfo.CustomerID = Customer.ID where InvoiceDate between @d1 and @d2 group by invoiceinfo.InvoiceDate,invoiceinfo.InvoiceNo,Customer.Name,InvoiceInfo.TotalPaid,invoiceinfo.Inv_ID
但查询显示擅长 sql server management studio 查询
这里是水晶报表和 sql server 管理工作室的屏幕截图
https://gyazo.com/569dad19a7957f35eb449fd45adf1177 https://gyazo.com/f8b6b8b56ab05c4c54a9b49e60ee6cae
此时请帮助我
【问题讨论】:
-
可以发一张水晶报表设计的屏幕截图吗?
-
是的,这里是水晶报表设计的截图gyazo.com/fc7558ee5ea4ac7b6ac48b7cfcbd6eab
-
这对我来说没有意义,但看起来客户端加入不是预期的结果。您能否将 Inv_ID 和 Name(客户名称)复制到详细信息会话并发布结果的屏幕截图?
标签: c# mysql sql-server vb.net crystal-reports