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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Report crashes in VB 1

Status
Not open for further replies.

anandkuppa

Programmer
May 31, 2001
5
GB
I had created a crystal report using a sub-report. The report, on its own,
runs very well without any problem and gives me the correct data.
But I have to call it through Visual Basic (version 6.0) and when I do that, my VB application crashes with a Dr.Watson error that says "An exception occurred
in <ADDRESS>&quot;

When i went through my code through the code debugger, I found that it was crashing at the place where I am putting

CRViewer1.ReportSource = m_Report

Where m_Report is an instance of my CRAXDRT.Report Object.

I have reproduced the code below for clarity:

CODE:

Dim m_App As New CRAXDRT.Application
Dim m_Report As New CRAXDRT.Report
Dim CRViewer1 As New Report

Private Sub Command1_Click()
Dim SQL As String
Dim strConnect As String

Set m_Report = m_App.NewReport
Set m_Report = m_App.OpenReport(&quot;d:\Management_Diary_Detailed.rpt&quot;, 1)

' Create and bind the ADO Recordset object
Set m_Connection = New ADODB.Connection
Set adoRS = New ADODB.Recordset

' Open the connection
strConnect = &quot;driver={SQL
Server};server=servername;uid=user;pwd=pwd;database=dbname&quot;
m_Connection.Open strConnect

SQL = &quot;Execute spManagementDiary_Detailed '30-Apr-2001', 2&quot;
adoRS.Open SQL, m_Connection, adOpenDynamic, adLockBatchOptimistic
m_Report.Database.SetDataSource adoRS

CRViewer1.ReportSource = m_Report
CRViewer1.ViewReport
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set m_Report = Nothing
End Sub

Since its been stopping my project from finishing, I would be glad if you could tell me where I am going wrong or if there is a problem with the DLL.

 
With a subreport, active data and a stored procedure you have lots of room for errors. It might help to eliminate some pieces and get a simpler report to work, and then add to it.

Can you launch a report from this code if it doesn't have a subreport?

If the report is to use a recordset, it must be created using the active data driver.

Also, change the line to read:

m_Report.Database.SetDataSource adoRS, 3

I believe that the last numeric argument is required. Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top