Hi Mark,
Finally, the right answers!
I had gotten some hard-to-understand suggestions in this direction from
Crystal, but the settings would not change using code very similar to yours.
I had just been guessing that the reason it wasn't working was because of
integrated security, and your remarks confirm that.
Now the last difficult part - how do I change from integrated security to a
login/pwd connection? Please let me know at your earliest convenience - and
thanks so much!
Bernie
"Mark Lauser .com>" <Mark@CrimsonSoftware<remove> wrote in message
news:9B889CC1-C0BC-424B-9FEC-(E-Mail Removed)...
> Bernie,
>
> I have gone through this, and the following code circumvents all of the
known bugs that I worked through to resolve the problem. Apparently there
are more obvious ways to handle this that simply don't work (or didn't when
I wrote the code).
>
> I store connection information in a 'Registration' dll file that is
located on each client. That way I can have an identical application
running on many different clients, and each uses it's own set of connection
info to get to the appropriate server and database. You could also use
application settings that the users can change themselves.
>
> With this in place, I can create or revise reports on my dev machine and
simply copy the report file to any and all clients with no changes at all,
which was the main goal. The clients do not need Crystal Reports, and you
certainly don't have to build the reports for each client.
>
> One note: this particular method will not work if you use Windows
Integrated Security to connect the report to the database on your dev
machine. So, if you used Integrated Security, and you want to use this
code, open each report, change the database connection to use a UserName &
Password, and re-save it. I informed Crystal that it would be really nice
if this could be changed at run-time, but I am not aware if they have
accomplished this yet.
>
> Declarations...
> Imports CrystalDecisions.Shared
> Imports CrystalDecisions.CrystalReports.Engine
>
> ...
> 'Pass connection info
> Dim crTableLogonInfo As New TableLogOnInfo
> Dim crConnectionInfo As New ConnectionInfo
> Dim crTable As Table
> Dim subRepDoc As New ReportDocument
> Dim crSection As Section
> Dim crReportObject As ReportObject
> Dim crSubreportObject As SubreportObject
> With crConnectionInfo
> .DatabaseName = <<Insert DatabaseName>>
> .ServerName = <<Insert ServerName or IP Address and Port>>
> .UserID = <<Insert UserID>>
> .Password = <<Insert Password>>
> End With
> crTableLogonInfo.ConnectionInfo = crConnectionInfo
>
> 'CurrentReport is the ReportDocument loaded from a file
earlier in this subroutine
> For Each crTable In CurrentReport.Database.Tables
> crTable.ApplyLogOnInfo(crTableLogonInfo)
> crTable.Location = crTable.Name
> Next
>
> 'If you have any sub-reports, they need the connection info
too...
> For Each crSection In CurrentReport.ReportDefinition.Sections
> For Each crReportObject In crSection.ReportObjects
> If crReportObject.Kind =
ReportObjectKind.SubreportObject Then
> crSubreportObject = CType(crReportObject,
SubreportObject)
> subRepDoc =
crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
> For Each crTable In subRepDoc.Database.Tables
> crTable.ApplyLogOnInfo(crTableLogonInfo)
> crTable.Location = crTable.Name
> Next
> End If
> Next
> Next
>
> 'ReportViewer is the Crystal Reports Forms viewer on my form
> ReportViewer.ReportSource = CurrentReport
>
>
> I hope this prevents the same headaches that I had to go through to get
here...
>
> Best Regards,
> Mark Lauser - Crimson Software
|