再问水晶报表9,如何动态改变数据库连接方式

jzd1997 2003-02-27 03:20:23
我用如下的代码想把报表的数据库动态设置为需要的路径,但是现在无法改变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
...全文
61 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
illfe 2003-02-28
  • 打赏
  • 举报
回复
可否寫一個完整的?謝
shellmark 2003-02-28
  • 打赏
  • 举报
回复
支持一下,收分
jzd1997 2003-02-27
  • 打赏
  • 举报
回复
自立更生,搞定了,我的代码如下
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset

Set CrReport = Appl.OpenReport(App.Path & "\rpt_FB0020.rpt") 'Open the Events.rpt report file.
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open "D:\work\医師\source\wmdb\KAIINMDB.mdb"
End With
Call rst.Open("FB0020", cnn, adOpenDynamic, adLockReadOnly, adCmdTable)
CrReport.ParameterFields(1).AddCurrentValue "abd"
CrReport.Database.SetDataSource rst
CRViewer91.ReportSource = CrReport 'Sets the Report source of the CrViewer to the Report object we created.


CRViewer91.ViewReport 'View the Report.

808

社区成员

发帖
与我相关
我的任务
社区描述
VB 多媒体
社区管理员
  • 多媒体
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧