【发布时间】:2020-07-08 14:24:45
【问题描述】:
我已经在 Google 上搜索过这个主题,并且按照我所看到的进行了编码,但是 CrystalReportViewer 是空的,我没有收到任何错误。我不确定我做错了什么。以下是我所有的代码。
strSQL = "select * from MMM_vw_Rpt_Summary where BudgetID = " & Master.lblBudgetIDText
ds = CreateDataset(strSQL, "cnn_rcg_mmm", "dt_Summary")
CreateSummary(ds)
Public Shared Function CreateDataset(ByVal strSQL As String, ByVal strCNN As String, ByVal strTable As String) As DataSet
Dim strConnString As String = ConfigurationManager.ConnectionStrings(strCNN).ConnectionString
Dim da As MySqlDataAdapter
Dim ds As DataSet
Dim strReturn As String
strReturn = ""
Try
Using con As New MySqlConnection(strConnString)
Dim cmd As New MySqlCommand(strSQL, con)
con.Open()
da = New MySqlDataAdapter(cmd)
ds = New dsLifeBudget
da.Fill(ds, strTable)
Return ds
con.Close()
End Using
Catch ex As Exception
strReturn = ex.Message
End Try
End Function
Protected Sub CreateSummary(ByVal ds As DataSet)
Dim strReportPath As String = Server.MapPath("~/Reports/LB_Summary.rpt")
Dim cr As New ReportDocument
Dim strError As String = ""
Master.HideMsg()
'Verify the path to the Crystal Report's .RPT file
If Not IO.File.Exists(strReportPath) Then
Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))
strError = "Unable to locate report file: " & strReportPath
Master.txtMsgText = "Error creating Summary - " & strError
Master.txtMsgVisible(True)
Exit Sub
End If
crLifeBudget.HasDrillUpButton = False
crLifeBudget.Height = "300px"
crLifeBudget.Width = "500px"
'Load the Crystal report's .RPT file and pass in the DataTable
cr.Load(strReportPath)
cr.SetDataSource(ds.Tables("dt_Summary"))
crLifeBudget.ReportSource = cr
crLifeBudget.RefreshReport()
End Sub
任何帮助将不胜感激! 埃迪·雷
【问题讨论】:
-
您确认您的数据集包含数据了吗?
-
是的。数据库确实有数据。
标签: asp.net vb.net crystal-reports