-
1
- #1
anandkuppa
Programmer
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>"
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("d:\Management_Diary_Detailed.rpt", 1)
' Create and bind the ADO Recordset object
Set m_Connection = New ADODB.Connection
Set adoRS = New ADODB.Recordset
' Open the connection
strConnect = "driver={SQL
Server};server=servername;uid=user;pwd=pwd;database=dbname"
m_Connection.Open strConnect
SQL = "Execute spManagementDiary_Detailed '30-Apr-2001', 2"
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.
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>"
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("d:\Management_Diary_Detailed.rpt", 1)
' Create and bind the ADO Recordset object
Set m_Connection = New ADODB.Connection
Set adoRS = New ADODB.Recordset
' Open the connection
strConnect = "driver={SQL
Server};server=servername;uid=user;pwd=pwd;database=dbname"
m_Connection.Open strConnect
SQL = "Execute spManagementDiary_Detailed '30-Apr-2001', 2"
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.