Showing posts with label crxapplication. Show all posts
Showing posts with label crxapplication. Show all posts

Tuesday, March 20, 2012

crystal reports (urgent)

Public crxapplication As CRAXDRT.Application
Public crxreport As CRAXDRT.Report

Dim strReportName As String
Dim Fltr
crxapplication = New CRAXDRT.Application

'Pass the reportname to string variable
strReportName = "CITIES"

'Get the Report Location
Dim strReportPath As String = "C:\ReportViwer\ReportViwer" & "\" & strReportName & ".rpt"
'Check file exists
If Not IO.File.Exists(strReportPath) Then
Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))
End If
crxreport = crxapplication.OpenReport(strReportPath)
crxreport.DiscardSavedData()

'Delete all the original parameter values from the parameter picklist.
'If you want to keep the orginal parameter values in the parameter picklist, comment out this loop.
Do Until crxreport.ParameterFields(1).NumberOfDefaultValues = 0
crxreport.ParameterFields(1).DeleteNthDefaultValue(1)
Loop
crxreport.Database.Tables(1).SetDataSource(RS, 3)
' Read the records to force the parameter box to appear before sending data to the viewer
crxreport.ReadRecords()
Fltr = "{CITY_CITIES.COUNTRY_NO}={?COUNTRY_NO}"
' Get the value the user enters in the parameter box then send that text to the formula field (that ' the report is grouped on)
crxreport.RecordSelectionFormula = Fltr
' View the report
AxCrystalActiveXReportViewer1.ViewReport()
End Sub

The error I am getting is An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in axinterop.crystalactivexreportviewerlib10.dll

Additional information: Unspecified error

Can I have your help please.Which line are you getting the error?