Private Shared Sub ApplyLogonToTables(ByVal objReport As ReportDocument)
Dim con As New SqlConnection(ConnectionStringFactory.GetConnectionString(Main.LoggedInUser.Login_ProjectCode))
Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo
Dim crTables As Tables = objReport.Database.Tables
For Each crTable As Table In crTables
With ConInfo.ConnectionInfo
.ServerName = ConnectionStringFactory.ConnectionServer
.DatabaseName =ConnectionStringFactory.ConnectionDBName
.UserID = ConnectionStringFactory.ConnectionUserID
.Password = ConnectionStringFactory.ConnectionPassword
End With
crTable.ApplyLogOnInfo(ConInfo)
Next
End Sub
以上代码在VS 2010的解决方案中运行良好所有项目都从VS2008转换为VS2010,但后来又在vs2010中添加了另一个项目,这个方法变得很慢 “Dim crTables As Tables = objReport.Database.Tables” 这条线大约需要60分钟。