再问水晶报表9,如何动态改变数据库连接方式
我用如下的代码想把报表的数据库动态设置为需要的路径,但是现在无法改变db连接
,哪位老大帮帮忙,谢谢了!
Dim WithEvents CrReport As CRAXDRT.Report 'Dim the report object with events.
Dim Appl As New CRAXDRT.Application
Private Sub Form_Load()
Dim Pw_MdbFname As String
Dim Pw_AppPath As String
Dim Pw_Ret As String
Pw_AppPath = App.Path
Pw_AppPath = IIf(Right(Pw_AppPath, 1) = "\", Pw_AppPath, Pw_AppPath & "\")
Set CrReport = Appl.OpenReport(Pw_AppPath & "rpt_FB0020.rpt") 'Open the Events.rpt report file.
If Not Gf_Get_Inifile("Path", "KAIINMDB", Pw_Ret) Then GoTo L_FormLoad
Pw_MdbFname = Replace(Pw_Ret, "\MDB", "\WMDB")
Pw_MdbFname = "E:\医師会管理システム\source\FB0020\mdb\KAIIN.MDB"
CrReport.DiscardSavedData
CrReport.Database.SetDataSource (Pw_MdbFname)
CrReport.Database.Verify
CrReport.ParameterFields(1).AddCurrentValue Format(Now, "yy/mm/dd hh:mm:ss")
CRViewer91.ReportSource = CrReport 'Sets the Report source of the CrViewer to the Report object we created.
CRViewer91.ViewReport 'View the Report.
Exit Sub
L_FormLoad:
End Sub