Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass connection info to report from VB.NET

Status
Not open for further replies.

CraigBest

Programmer
Aug 1, 2001
545
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top