Hello,
I am using VS 2005 and SQL Server 2005.
I have a dataset in which I am using to populate parameter fields in Crystal Reports. I want to loop through the dataset and display each row of information on the report.
I am encountering two problems. My first problem is that when I try the loop, the previous row is overwritten with the current row.
Here is my code. I am only referencing 2 rows for testing purposes.
My second problem is that my crystal report file is stored in the project directory with the rest of my forms, yet the directory searches in the project\bin\debug directory. How can I search the proper directory?
Can anyone help with these two situations or provide me with a better method to pass values to crystal reports.
Thanks.
I am using VS 2005 and SQL Server 2005.
I have a dataset in which I am using to populate parameter fields in Crystal Reports. I want to loop through the dataset and display each row of information on the report.
I am encountering two problems. My first problem is that when I try the loop, the previous row is overwritten with the current row.
Here is my code. I am only referencing 2 rows for testing purposes.
Code:
Private Sub PrintPreview()
Dim l_daPrint As New SqlDataAdapter
Dim l_dsPrint As New DataSet
Dim rptDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim frmView As New frmViewer
Dim strReportName As String = "ListingOfModels"
Dim strReportPath As String
strReportPath = My.Application.Info.DirectoryPath & "\" & strReportName & ".rpt"
l_daPrint.SelectCommand = New SqlCommand
With l_daPrint.SelectCommand
.Connection = acCONN
.CommandType = CommandType.Text
.CommandText = "SELECT * from cusform WHERE (RefNum IN ('KIKU-120602-3', 'KIKU-120602-3.'))"
End With
l_dsPrint.Clear()
l_daPrint.Fill(l_dsPrint, "ModelPrintInfo")
rptDocument.Load(strReportPath)
rptDocument.SetDataSource(l_dsPrint)
For Each Row As DataRow In l_dsPrint.Tables(0).Rows
rptDocument.SetParameterValue("pDate", Row.Item("DT"))
rptDocument.SetParameterValue("pImpNum", Row.Item("ImpNum"))
rptDocument.SetParameterValue("pImpName", Row.Item("ImpName"))
rptDocument.SetParameterValue("pRefNum", Row.Item("RefNum"))
rptDocument.SetParameterValue("pArtNum", Row.Item("NO_ARTS"))
Next
frmView.CRViewer.ReportSource = rptDocument
frmView.WindowState = FormWindowState.Maximized
frmView.Show()
End Sub
My second problem is that my crystal report file is stored in the project directory with the rest of my forms, yet the directory searches in the project\bin\debug directory. How can I search the proper directory?
Can anyone help with these two situations or provide me with a better method to pass values to crystal reports.
Thanks.