
Setting Information at Runtime ("Server has not yet been opened" - again)
One thing I forgot to ask...are you using subqueries? If so, you need to
loop through the subqueries in your report and do the same as with the
initial table. I'm being lazy and posting the code I have on another thread
here that uses the .Net namespace for Crystal Reports, but you get the idea.
crConnectionInfo = New ConnectionInfo()
With crConnectionInfo
.ServerName = ServerName
.DatabaseName = DatabaseName
.UserID = UserId
.Password = Password
End With
For Each crTable In m_objReport.Database.Tables
crTableLogonInfo = crTable.LogOnInfo
crTableLogonInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogonInfo)
Next
For Each crSection In m_objReport.ReportDefinition.Sections
For Each crReportObject In crSection.ReportObjects
If crReportObject.Kind
=CrystalDecisions.[Shared].ReportObjectKind.SubreportObject Then
crSubReport = CType(crReportObject,
CrystalDecisions.CrystalReports.Engine.SubreportObject)
crSubReportDoc
=crSubReport.OpenSubreport(crSubReport.SubreportName)
For Each crTable In crSubReportDoc.Database.Tables
crTableLogonInfo = crTable.LogOnInfo
crTableLogonInfo.ConnectionInfo
=crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogonInfo)
Next
End If
Next
Next
crConnectionInfo = Nothing
I feel your pain. I am struggling to find an answer to how to change a
datasource location dynamically. Using the techniques recommended from
Crystal using the .Net components (as above) does not change the data
source. It will authenticate against the data source that I choose, but it
will pull data from the original data source. Go figure. See my other post
in this newsgroup for more detail.
Quote:
> Thanks for your suggestion. However we do not want to set up a DSN on
> the end users computer. We played with idea for a while and it did
> work, but we are keen to avoide using a dsn if at all possible.