0
votes

I have been trying to browse a SQL Server database-based Crystal Reports version 8 with following Visual Basic code:

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

I am using the Crystal Reports control. The database of the report is ODBC datasource connecting to SQL Server. Without DiscardSavedData this works, but it displays old data. With DiscardSavedData, I get the error message:

  • Error 20599 Cannot open SQL Server.

How do I solve this problem?

1
Have you set the connection information in your code? Have a look at this post, it might help you p2p.wrox.com/pro-vb-databases/… - lardymonkey
I didn't specify which connection info, it is the CrystalReport1,Connect = the DSN / Connection string - lardymonkey

1 Answers

0
votes

i have solved my issus by adding the connection string CrystalReport1.Connect, i'd like to share my solution for all.

 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