I have developed a method that sets the Crystal Reports Connection.
This method first grabs the connection string from the config file creates a Crystal Reports ConnectionInfo object.
The following code then takes over 5 seconds to run:
Dim myTables As Tables = report.Database.Tables
Dim myTableLogonInfo As TableLogOnInfo = New TableLogOnInfo()
myTableLogonInfo.ConnectionInfo = myConnectionInfo
Then this code takes over 6 seconds to run:
For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
myTable.ApplyLogOnInfo(myTableLogonInfo)
myTable.LogOnInfo.ConnectionInfo.DatabaseName = myTableLogonInfo.ConnectionInfo.DatabaseName
myTable.LogOnInfo.ConnectionInfo.ServerName = myTableLogonInfo.ConnectionInfo.ServerName
myTable.LogOnInfo.ConnectionInfo.UserID = myTableLogonInfo.ConnectionInfo.UserID
myTable.LogOnInfo.ConnectionInfo.Password = myTableLogonInfo.ConnectionInfo.Password
Next
This only occurs the first time that the form is loaded, the subsequent times it is
335ms (as compared to 5349ms) and 52ms (as compared to 6228ms)
However, when the application is reloaded the same slow times re-occur.
There are not many different tables in my report generally 3 or less. Only 1 table in this case.
This is currently in test and VS2008 and SQLServer2005 are both running locally. The same issue does occur in the QA environment as well, where the application is run on the client and the database is on a server on the same LAN.
So my question is, can I improve the speed of this portion of code? Why does it take so long to set the report connection information? Am I doing connections to the report incorrectly?
Any ideas?
Thanks,