回复 2楼 ZHRXJR
执行存储过程,调用显示SUMREPORT.RPT报表 就会报错
存储过程中有多个临时表,是不是因为这些临时表的问题导致的,其他没有临时表的存储过程执行就没有问题
Public Function openRs(ByVal strsql As String) As Boolean
Dim mag As String
Dim rpy As Boolean
On Error GoTo err
Set rs = New ADODB.Recordset
If addFlag = False Then rpy = True
With rs
.ActiveConnection = conn
.CursorLocation = adUseClient
' 这里更改为adUseServer也不行
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open strsql
End With
addFlag = True
openRs = True
Exit Function
err:
End Function
Private Sub Command1_Click()
Call openRs("sp_executesql
hrReport")
PrintReportName = "sumreport.rpt"
PrintFrm.Show 1
End Sub
Private Sub Form_Load()
Dim oApp As New CRAXDRT.Application
Dim oRpt As CRAXDRT.Report
Dim reportName As String
Screen.MousePointer = vbHourglass
reportName = "\" & PrintReportName 'report1.rpt"
Set oRpt = oApp.OpenReport(App.Path & reportName, 1)
oRpt.DiscardSavedData
oRpt.Database.SetDataSource rs
oRpt.ReadRecords
CRViewer1.ReportSource = oRpt
CRViewer1.ViewReport
CRViewer1.Refresh
Screen.MousePointer = vbDefault
End Sub