如何 select 来自 table 的记录用于 crystal 在 vb.net 中的报告?

How to select records from table for crystal report in vb.net?

我在 msaccess 数据库中将 table 命名为产品,我已将 crystal 报告添加到我的项目中,但它显示了来自 table 的所有记录,我想在两者之间进行过滤使用 MS 访问查询的两个日期,但我不知道该怎么做...源代码是


Dim report As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim cmd1 As OleDbCommand = New OleDbCommand("SELECT distinct invoice,productname,amount from product where  date between '" & date1.Text & "' and '" & date2.Text & "'", con)
        myDA = New OleDbDataAdapter(cmd1)
        myDataSet = New DataSet()
        myDA.Fill(myDataSet, "outwardp")
        saledtereport.CrystalReportViewer1.ReportSource = myDataSet
        saledtereport.ShowDialog()

我是 crystal 报告的新手,请开发人员帮助我解决这个问题.. 提前致谢。

您不能将数据集设置为报表源 报告源应该是您创建的报告,并且您希望在该报告查看器中显示 然后只有您可以将数据集添加到报告中

    Dim rpt As New pos_rpt_finalreportcr 'name of the crystal report that you have created 
                    rpt.Load(Server.MapPath("pos_rpt_finalreportcr.rpt")) 
                    CrystalReportViewer1.ReportSource = rpt 
                    rpt.SetDataSource(myDS)
                    rpt.Refresh()

希望对您有所帮助。