chintapalli
Programmer
Hi,
I am calling a crystal report from Visual Basic 6.0. I call a Stored Procedure to get data in a record set. I am able to get the data from the database. But I get error "Unable to Access first record" when I am trying to export the record set data to a file. Does anyone know why I get this error?
P.S.: Instead of Stored Procedure if I execute my query directly from ADO I am able to export the file i.e. the following code works
rsIndiv.Open "Select * From MyTable", objConn, adOpenKeyset, adLockOptimistic
Here is my code which does NOT work:
********************************************************************
Dim Report As New dsrIndividualReport 'The individual report, a crstal reports designer object
Dim dsrSubReport As CRAXDRT.Report 'A crstal reports report object needed to hook into the narrative subreport so that we can pass the recordset into it
With objConnection
.ConnectionString = strConnection
.Open
End With
With objCommand
.ActiveConnection = objConnection
.CommandText = "Pilot"
.CommandType = adCmdStoredProc
End With
'**** Append parameters to the Stored procedure
Set objParamParticipantID = objCommand.CreateParameter("@ParticipantUserId", adInteger, adParamInput, , intParticipantID)
Set objParamTranslationID = objCommand.CreateParameter("@TranslationId", adInteger, adParamInput, , intTranslationID)
objCommand.Parameters.Append objParamParticipantID
objCommand.Parameters.Append objParamTranslationID
objRecordSet.CursorType = adOpenDynamic
objRecordSet.CursorLocation = adUseClient
Set objRecordSet = objCommand.Execute
' Set the Report's datasource to the recordset
Report.Database.SetDataSource objRecordSet
'Set dsrSubreport to be the subreport1 (narrative)
'Set dsrSubReport = Report.Subreport1.OpenSubreport
'Set the datasource of the subreport to be the recordset
'dsrSubReport.Database.SetDataSource objRecordSet
' generate a pdf report to disk
Report.ExportOptions.DiskFileName = strFileName
Report.ExportOptions.DestinationType = crEDTDiskFile
Report.ExportOptions.FormatType = crEFTPortableDocFormat
I am calling a crystal report from Visual Basic 6.0. I call a Stored Procedure to get data in a record set. I am able to get the data from the database. But I get error "Unable to Access first record" when I am trying to export the record set data to a file. Does anyone know why I get this error?
P.S.: Instead of Stored Procedure if I execute my query directly from ADO I am able to export the file i.e. the following code works
rsIndiv.Open "Select * From MyTable", objConn, adOpenKeyset, adLockOptimistic
Here is my code which does NOT work:
********************************************************************
Dim Report As New dsrIndividualReport 'The individual report, a crstal reports designer object
Dim dsrSubReport As CRAXDRT.Report 'A crstal reports report object needed to hook into the narrative subreport so that we can pass the recordset into it
With objConnection
.ConnectionString = strConnection
.Open
End With
With objCommand
.ActiveConnection = objConnection
.CommandText = "Pilot"
.CommandType = adCmdStoredProc
End With
'**** Append parameters to the Stored procedure
Set objParamParticipantID = objCommand.CreateParameter("@ParticipantUserId", adInteger, adParamInput, , intParticipantID)
Set objParamTranslationID = objCommand.CreateParameter("@TranslationId", adInteger, adParamInput, , intTranslationID)
objCommand.Parameters.Append objParamParticipantID
objCommand.Parameters.Append objParamTranslationID
objRecordSet.CursorType = adOpenDynamic
objRecordSet.CursorLocation = adUseClient
Set objRecordSet = objCommand.Execute
' Set the Report's datasource to the recordset
Report.Database.SetDataSource objRecordSet
'Set dsrSubreport to be the subreport1 (narrative)
'Set dsrSubReport = Report.Subreport1.OpenSubreport
'Set the datasource of the subreport to be the recordset
'dsrSubReport.Database.SetDataSource objRecordSet
' generate a pdf report to disk
Report.ExportOptions.DiskFileName = strFileName
Report.ExportOptions.DestinationType = crEDTDiskFile
Report.ExportOptions.FormatType = crEFTPortableDocFormat