469,356 Members | 1,989 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

Change Report Connection at Runtime

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
....
--
Mar 2 '06 #1
6 4552
"pearsons_11114" <pe***********@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/p...rystal_dev.asp

Armin
Mar 2 '06 #2


"Armin Zingler" wrote:

Have you already had a look at the manufacturer's KB or the forums here?
http://support.businessobjects.com/p...rystal_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.
Mar 2 '06 #3
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.
Mar 2 '06 #4
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
Mar 3 '06 #5
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.

"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

Mar 3 '06 #6
Turns out it is a Crystal bug that is fixed in the latest patch. (1/2006)

"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.

Mar 6 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Grant Stanley | last post: by
6 posts views Thread by thomas.jacobs | last post: by
reply views Thread by Timmy Jones | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.