I'm trying to update the record source for my report from my
VB.NET application. This is the code I'm using:
Public Function SetReportConnection(ByVal oRpt As ReportDocument) As ReportDocument
Try
Dim crTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
Dim crConnectionInfo As CrystalDecisions.Shared.ConnectionInfo
Dim crTable As Table
Dim strName As String
crTableLogonInfo = New TableLogOnInfo()
crConnectionInfo = New ConnectionInfo()
crConnectionInfo.ServerName = clsSQLLogin.strServerName
crConnectionInfo.DatabaseName = clsSQLLogin.strDB
crConnectionInfo.UserID = clsSQLLogin.strUserName
crConnectionInfo.Password = clsSQLLogin.strPassWord
crTableLogonInfo.ConnectionInfo = crConnectionInfo
For Each crTable In oRpt.Database.Tables
crTable.ApplyLogOnInfo(crTableLogonInfo)
Next
Try
strName = oRpt.Database.Tables(0).Location.ToString
oRpt.Database.Tables(0).Location = strName
Catch ex As Exception
MessageBox.Show(ex.Message & ex.GetType.ToString)
Finally
SetReportConnection = oRpt
End Try
Catch ex As Exception
MessageBox.Show(ex.Message & ex.GetType.ToString)
End Try
End Function
The lines regarding getting and setting the Location were given to me by Crystal Decisions help and work MOST of the time. It is apparently required to force the report to update it's record source. However, I have a report that was working great and all of a sudden, it gets to that line and just hangs. No error message, the program just stops responding. Does anyone have any better idea on how to handle this?