错误20599无法使用VB6 / Crystal报表打开SQL Server

问题描述 投票:0回答:1

我一直在尝试使用以下Visual Basic代码浏览基于SQL Server数据库的Crystal Reports版本8:

CrystalReport1.ReportFileName = "C:\Report1.rpt"
CrystalReport1.Destination = crptToWindow
CrystalReport1.DiscardSavedData = True
CrystalReport1.WindowState = crptMaximized
MsgBox "Ok!", vbInformation
CrystalReport1.Action = 1

我正在使用Crystal Reports控件。该报告的数据库是连接到SQL Server的ODBC datasource。没有DiscardSavedData这可行,但它显示旧数据。使用DiscardSavedData,我收到错误消息:

  • 错误20599无法打开SQL Server。

我该如何解决这个问题?

crystal-reports vb6 odbc
1个回答
0
投票

我通过添加连接字符串CrystalReport1.Connect解决了我的问题,我想分享我的解决方案。

 CrystalReport1.ReportFileName = "C:\Report1.rpt"
    CrystalReport1.Destination = crptToWindow
    CrystalReport1.DiscardSavedData = True
    CrystalReport1.Connect ="Data Source=Localhost;UID=sa;PWD=****;DSQ=Dat BdName;"
    CrystalReport1.WindowState = crptMaximized
CrystalReport1.Action = 1
© www.soinside.com 2019 - 2024. All rights reserved.