使用SELECT命令的Crystal报表

时间:2019-02-12 09:33:30

标签: vb.net-2010 crystal-reports-2010

我已经在数据库字段中连接或添加了数据库(MS ACCESS)。 但问题是我无法打印甚至无法查看数据。

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim str As String
    str = "Select * From Grade2 WHERE [LRN] = '" & TextBox2.Text & "'"
    Command.CommandText = str
    Command.Connection = Connection
    Adapter.SelectCommand = Command
    Adapter.Fill(DataSet)

    reportname = "Report1"
    Dim reportpath As String = Application.StartupPath & "\" & reportname & ".rpt"
    If Not IO.File.Exists(reportpath) Then
        Throw (New Exception("Unable to locate report file: " & vbCrLf & reportpath))
    End If

    Dim rptdocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
    rptdocument.SetDataSource(reportpath)
    Print.CrystalReportViewer1.ReportSource = rptdocument
    Print.CrystalReportViewer1.Refresh()

    Print.ShowDialog()
End Sub

0 个答案:

没有答案