Manesti
Member
- Joined
- Jan 16, 2009
- Messages
- 16
- Programming Experience
- Beginner
Please what really is wrong with this code; I have a dataset.xsd and a datatable in it. I have also connected my crystal report to the dataset, but the report displays notin.
Private Sub printwithCahrt(ByVal sql As String)
Dim constring As String = WebConfigurationManager.ConnectionStrings("FRSC").ConnectionString
Dim con As New SqlConnection(constring)
Dim cmd As SqlCommand
cmd = New SqlCommand(sql, con)
Dim Dataset1 As New DataSet
Dim DA As New SqlDataAdapter
DA.SelectCommand = cmd
DA.Fill(Dataset1, "DataTable3")
Dim strReportName As String = "CrystalReport2"
'Get the Report Location
Dim strReportPath As String = Server.MapPath(strReportName & ".rpt")
'Check file exists
If Not IO.File.Exists(strReportPath) Then
Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))
End If
'Assign the datasource and set the properties for Report viewer
Dim rptDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rptDocument.Load(strReportPath)
rptDocument.SetDataSource(Dataset1.Tables("DataTable3"))
CrystalReportViewer1.ReportSource = rptDocument
End Sub
the dataTable3 is the same name I used in th dataset. The report just appears empty.
Thank you very much
Private Sub printwithCahrt(ByVal sql As String)
Dim constring As String = WebConfigurationManager.ConnectionStrings("FRSC").ConnectionString
Dim con As New SqlConnection(constring)
Dim cmd As SqlCommand
cmd = New SqlCommand(sql, con)
Dim Dataset1 As New DataSet
Dim DA As New SqlDataAdapter
DA.SelectCommand = cmd
DA.Fill(Dataset1, "DataTable3")
Dim strReportName As String = "CrystalReport2"
'Get the Report Location
Dim strReportPath As String = Server.MapPath(strReportName & ".rpt")
'Check file exists
If Not IO.File.Exists(strReportPath) Then
Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))
End If
'Assign the datasource and set the properties for Report viewer
Dim rptDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rptDocument.Load(strReportPath)
rptDocument.SetDataSource(Dataset1.Tables("DataTable3"))
CrystalReportViewer1.ReportSource = rptDocument
End Sub
the dataTable3 is the same name I used in th dataset. The report just appears empty.
Thank you very much