Home All Groups Group Topic Archive Search About

Change Report Connection at Runtime

Author
2 Mar 2006 5:50 PM
pearsons_11114
Changing connection info at run time with Crystal does not seem to work as
advertised. I've tried the code in the documentation and the code that's been
posted in the crystal group numerous times by Shariq. Here are my particulars:

..NET 1.1, SP1
Crystal Dev. 10
SQL Server
Report has one table (a command), and no subreports.

As long as I pass in a server name of "(local)", it works fine, no login
popup. Substituting any other value, including the local machine name or
"localhost" pops the login dialog. Even though correct credentials are
entered, it doesn't accept them. Oddly, the server and database fields are
grayed out and blank. I have verified in the debugger that the parameters are
being changed in the ConnectionInfo object. I also notice that there's an
undocumented member, ConnectionInfo.AllowCustomConnection, but toggling it
did not affect the outcome. I'm stumped. Seems like a lot of other people
are too. Thx.

--
Public Sub RunReport(ByVal myReport As ReportDocument)
Dim ReportViewer As ReportViewerForm

Dim myConnectionInfo As New ConnectionInfo
Dim myLogonInfo As New TableLogOnInfo
'myConnectionInfo.AllowCustomConnection() = True
myConnectionInfo.ServerName = "myServerName"
myConnectionInfo.DatabaseName = "myDatabaseName"
myConnectionInfo.UserID = "myUserId"
myConnectionInfo.Password = "myPassword"
For Each myTable As Table In myReport.Database.Tables
myLogonInfo = myTable.LogOnInfo
myLogonInfo.ConnectionInfo = myConnectionInfo
myTable.ApplyLogOnInfo(myLogonInfo)
Next
....
--

Author
2 Mar 2006 8:00 PM
Armin Zingler
"pearsons_11114" <pearsons11***@discussions.microsoft.com> schrieb
> Changing connection info at run time with Crystal does not seem to
> work as advertised. I've tried the code in the documentation and the
> code that's been posted in the crystal group numerous times by
> Shariq. Here are my particulars:


Have you already had a look at the manufacturer's KB or the forums here?
http://support.businessobjects.com/programs/crystal_dev.asp



Armin
Author
2 Mar 2006 8:42 PM
pearsons_11114
"Armin Zingler" wrote:

>
> Have you already had a look at the manufacturer's KB or the forums here?
> http://support.businessobjects.com/programs/crystal_dev.asp
>

I've scoured the knowledge base and newsgroups here. Essentially the same
sample code is posted everywhere I've found anything, but that code does not
work. The details of how it doesn't work are in the original post. I've also
noticed the same question asked a few times, but not answered. Seems like a
pretty basic showstopper not to be able to do this, so I have to figure that
there is another step that is missing from the documentation. Hopefully
someone else here has used the product in a real environment and has figured
out how to do this.

I've also checked the Business Objects site, but we all know how generally
futile that is.  ;-) They have another version of the code that apparently
replaces each table instead of just updating its connection. Be trying that
next.
Author
2 Mar 2006 9:56 PM
pearsons_11114
Ok, some further information. This problem only seems to happen if the
"table" in quesiton is a command. As long as it's an actual table, no
problem. Can anyone shed any light on this? Thx.
Author
3 Mar 2006 3:13 PM
Jason Hunt
Hello pearsons_11114,

Here is how I do it:

        Dim CnInfo As New CrystalDecisions.Shared.ConnectionInfo
        CnInfo.DatabaseName = "mydatabase"
        CnInfo.Password = "mypassword"
        CnInfo.ServerName = "myserver"
        CnInfo.UserID = "myuser"

        For Each entry As TableLogOnInfo In crpViewer.LogOnInfo
            entry.ConnectionInfo = CnInfo
        Next


Rather than creating new TableLogOnInfo object, I'm just modifying the existing
ones.  Hope this helps.

--
Jason Hunt
Advanced Computer Systems
Author
3 Mar 2006 3:28 PM
pearsons_11114
What's crpViewer? You don't define it in the code. I tried using the
ReportViewer, but it doesn't have that member. Your code make it seem like
there is one object that holds all the LogOnInfo objects, but AFAIK they only
exist in each table. Thanks for any clarification.

Also do you find that this works when the table is actually a command? In my
testing, that's where the problem is.

Show quoteHide quote
"Jason Hunt" wrote:

> Hello pearsons_11114,
>
> Here is how I do it:
>
>         Dim CnInfo As New CrystalDecisions.Shared.ConnectionInfo
>         CnInfo.DatabaseName = "mydatabase"
>         CnInfo.Password = "mypassword"
>         CnInfo.ServerName = "myserver"
>         CnInfo.UserID = "myuser"
>
>         For Each entry As TableLogOnInfo In crpViewer.LogOnInfo
>             entry.ConnectionInfo = CnInfo
>         Next
>
>
> Rather than creating new TableLogOnInfo object, I'm just modifying the existing
> ones.  Hope this helps.
>
> --
> Jason Hunt
> Advanced Computer Systems
>
>
>
Author
6 Mar 2006 11:34 PM
pearsons_11114
Turns out it is a Crystal bug that is fixed in the latest patch. (1/2006)

Show quoteHide quote
"pearsons_11114" wrote:

> Ok, some further information. This problem only seems to happen if the
> "table" in quesiton is a command. As long as it's an actual table, no
> problem. Can anyone shed any light on this? Thx.