Hope someone can help me...
I have a VB.NET application that I want to integrate some Crystal Reports with. We can't seem to figure out how to pass the connection info to the report when calling the report from the application though.
Here's the source code:
----------------------------------
Const REPORT_FOLDER = "X:\Development\OnD\Reports\"
Sub RunReports()
'Create the parameter objects
Dim ParameterFields As New CrystalDecisions.Shared.ParameterFields()
Dim ParameterField1 As New CrystalDecisions.Shared.ParameterField()
Dim spValue As New CrystalDecisions.Shared.ParameterDiscreteValue()
m_sReportName = REPORT_FOLDER & m_sReportName
'Add ID parameter
ParameterField1.ParameterFieldName = "CorpID"
ParameterField1.ParameterType = CrystalDecisions.[Shared].ParameterType.ReportParameter
spValue.Value = m_CorpID
ParameterField1.CurrentValues.Add(spValue)
ParameterFields.Clear()
ParameterFields.Add(ParameterField1)
Try
CrystalReportViewer1.ParameterFieldInfo = ParameterFields
CrystalReportViewer1.DisplayGroupTree = False
With CrystalReportViewer1
.ReportSource = m_sReportName
End With
Catch ex As Exception
MessageBox.Show(ex.Message.ToString)
End Try
End Sub
----------------------------------
When we run this we get prompted for the database connection info. It is supposed to be using and ODBC DSN that we have created for an MS Access database.
Can someone tell me how to get the connection info across to the report viewer before the report is actually called?
Thanks in advance
Craig in NJ
I have a VB.NET application that I want to integrate some Crystal Reports with. We can't seem to figure out how to pass the connection info to the report when calling the report from the application though.
Here's the source code:
----------------------------------
Const REPORT_FOLDER = "X:\Development\OnD\Reports\"
Sub RunReports()
'Create the parameter objects
Dim ParameterFields As New CrystalDecisions.Shared.ParameterFields()
Dim ParameterField1 As New CrystalDecisions.Shared.ParameterField()
Dim spValue As New CrystalDecisions.Shared.ParameterDiscreteValue()
m_sReportName = REPORT_FOLDER & m_sReportName
'Add ID parameter
ParameterField1.ParameterFieldName = "CorpID"
ParameterField1.ParameterType = CrystalDecisions.[Shared].ParameterType.ReportParameter
spValue.Value = m_CorpID
ParameterField1.CurrentValues.Add(spValue)
ParameterFields.Clear()
ParameterFields.Add(ParameterField1)
Try
CrystalReportViewer1.ParameterFieldInfo = ParameterFields
CrystalReportViewer1.DisplayGroupTree = False
With CrystalReportViewer1
.ReportSource = m_sReportName
End With
Catch ex As Exception
MessageBox.Show(ex.Message.ToString)
End Try
End Sub
----------------------------------
When we run this we get prompted for the database connection info. It is supposed to be using and ODBC DSN that we have created for an MS Access database.
Can someone tell me how to get the connection info across to the report viewer before the report is actually called?
Thanks in advance
Craig in NJ