我也碰到了这个问题,花费了不少时间,解决方法如下:1.数据库的动态连接如下 Public crwReport As CRAXDRT.Report Private Const OracleDll = "crdb_oracle.dll" Private Function LogOn(ByVal LsSql As String) As Boolean Dim LsUser As String '用户 Dim LsPwd As String '密码 Dim LsSrv As String 'db Dim LoDBTable As CRAXDRT.DatabaseTable Screen.MousePointer = vbHourglass For Each LoDBTable In crwReport.Database.Tables If LoDBTable.DllName <> OracleDll Then LoDBTable.DllName = OracleDll End If With LoDBTable.ConnectionProperties .DeleteAll .Add "Server", LsSrv .Add "User ID", LsUser .Add "Password", LsPwd End With Next 2.将水晶报表中的数据库连接中的[现在数据库连接项]logoff掉,这样才能在vb代码中设置数据库, 否则数据库将被固定掉.如果解决不了的话,联系地址 [email protected]
Option Explicit Public adoPrimaryRS1 As New Recordset Public adoPrimaryRS2 As New Recordset Public adoPrimaryRS3 As New Recordset Public adoPrimaryRS4 As New Recordset Public adoPrimaryRS5 As New Recordset Public adoPrimaryRS6 As New RecordsetDim CPProperty As CRAXDRT.ConnectionProperty Dim DBTable As CRAXDRT.DatabaseTableDim m_report As CRAXDRT.Report Dim m_application As CRAXDRT.Application Private Sub CRViewer91_PrintButtonClicked(UseDefault As Boolean) m_report.PrinterSetup Me.hWnd End Sub Private Sub Form_Load() On Error Resume NextSet m_application = New CRAXDRT.Application Set m_report = m_application.OpenReport(App.Path + "\AR报表\c生产单.rpt")m_report.PaperOrientation = crLandscape m_report.DiscardSavedData m_report.Database.SetDataSource adoPrimaryRS1, 3, 1 '用户单位信息表 m_report.Database.SetDataSource adoPrimaryRS2, 3, 2 '基本信息 m_report.Database.SetDataSource adoPrimaryRS3, 3, 3 '工种 m_report.Database.SetDataSource adoPrimaryRS4, 3, 4 '物品 m_report.Database.SetDataSource adoPrimaryRS5, 3, 5 '项目 m_report.Database.SetDataSource adoPrimaryRS6, 3, 6 '车间名称 Screen.MousePointer = vbHourglass CRViewer91.ReportSource = m_report CRViewer91.ViewReport Screen.MousePointer = vbDefaultIf idDisplayMode = 1 Then CRViewer91.Zoom (75) Else CRViewer91.Zoom (50) End If End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)Set adoPrimaryRS1 = Nothing Set adoPrimaryRS2 = Nothing Set adoPrimaryRS3 = Nothing Set adoPrimaryRS4 = Nothing Set adoPrimaryRS5 = Nothing Set adoPrimaryRS6 = NothingSet CPProperty = Nothing Set DBTable = Nothing Set m_report = Nothing End SubPrivate Sub Form_Resize() CRViewer91.Top = 0 CRViewer91.Left = 100 CRViewer91.Height = ScaleHeight CRViewer91.Width = ScaleWidthEnd Sub
Public crwReport As CRAXDRT.Report
Private Const OracleDll = "crdb_oracle.dll"
Private Function LogOn(ByVal LsSql As String) As Boolean
Dim LsUser As String '用户
Dim LsPwd As String '密码
Dim LsSrv As String 'db
Dim LoDBTable As CRAXDRT.DatabaseTable Screen.MousePointer = vbHourglass
For Each LoDBTable In crwReport.Database.Tables
If LoDBTable.DllName <> OracleDll Then
LoDBTable.DllName = OracleDll
End If
With LoDBTable.ConnectionProperties
.DeleteAll
.Add "Server", LsSrv
.Add "User ID", LsUser
.Add "Password", LsPwd
End With
Next
2.将水晶报表中的数据库连接中的[现在数据库连接项]logoff掉,这样才能在vb代码中设置数据库,
否则数据库将被固定掉.如果解决不了的话,联系地址 [email protected]
Public adoPrimaryRS1 As New Recordset
Public adoPrimaryRS2 As New Recordset
Public adoPrimaryRS3 As New Recordset
Public adoPrimaryRS4 As New Recordset
Public adoPrimaryRS5 As New Recordset
Public adoPrimaryRS6 As New RecordsetDim CPProperty As CRAXDRT.ConnectionProperty
Dim DBTable As CRAXDRT.DatabaseTableDim m_report As CRAXDRT.Report
Dim m_application As CRAXDRT.Application
Private Sub CRViewer91_PrintButtonClicked(UseDefault As Boolean)
m_report.PrinterSetup Me.hWnd
End Sub
Private Sub Form_Load()
On Error Resume NextSet m_application = New CRAXDRT.Application
Set m_report = m_application.OpenReport(App.Path + "\AR报表\c生产单.rpt")m_report.PaperOrientation = crLandscape
m_report.DiscardSavedData
m_report.Database.SetDataSource adoPrimaryRS1, 3, 1 '用户单位信息表
m_report.Database.SetDataSource adoPrimaryRS2, 3, 2 '基本信息
m_report.Database.SetDataSource adoPrimaryRS3, 3, 3 '工种
m_report.Database.SetDataSource adoPrimaryRS4, 3, 4 '物品
m_report.Database.SetDataSource adoPrimaryRS5, 3, 5 '项目
m_report.Database.SetDataSource adoPrimaryRS6, 3, 6 '车间名称
Screen.MousePointer = vbHourglass
CRViewer91.ReportSource = m_report
CRViewer91.ViewReport
Screen.MousePointer = vbDefaultIf idDisplayMode = 1 Then
CRViewer91.Zoom (75)
Else
CRViewer91.Zoom (50)
End If
End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)Set adoPrimaryRS1 = Nothing
Set adoPrimaryRS2 = Nothing
Set adoPrimaryRS3 = Nothing
Set adoPrimaryRS4 = Nothing
Set adoPrimaryRS5 = Nothing
Set adoPrimaryRS6 = NothingSet CPProperty = Nothing
Set DBTable = Nothing
Set m_report = Nothing
End SubPrivate Sub Form_Resize()
CRViewer91.Top = 0
CRViewer91.Left = 100
CRViewer91.Height = ScaleHeight
CRViewer91.Width = ScaleWidthEnd Sub
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
http://expert.csdn.net/Expert/topic/2810/2810291.xml?temp=.5317346
Craxdrt9.dll和Craxddrt9.dll在C:\winnt\Crystal\目錄下