Crystal Reports 10 - How to set Server and DataBase At runtime.

R

runningdog

Hi,

I'm trying to set the servername and database for an untyped report at
runtime.
It seems I should do something like the following.

Dim Table As Table
Dim LogonInfo As New TableLogOnInfo
For Each Table In reportDocument.Database.Tables
LogonInfo = Table.LogOnInfo
LogonInfo.ConnectionInfo.ServerName = ConnectString.DataSource
LogonInfo.ConnectionInfo.DatabaseName = ConnectString.InitialCatalog
Table.ApplyLogOnInfo(LogonInfo)
Next

However I get the following error:
:Value of type 'CrystalDecisions.Shared.TableLogOnInfo' cannot be converted
to 'CrystalDecisions.Shared.TableLogOnInfo'.

Can someone point me in the right direction?


TIA Steve
 
P

Peter Huang

Hi Steve,

I think you may take a look at the link below and try to run the steps in
the links to see if the problem persists.
Crystal Report 8.5 for Visual Studio.NET (using C#)
http://www.dotnetforce.com/(kfofub553nl5l345kcra2n55)/Content.aspx?t=a&n=179

When did the problem occur in the runtime or the compile time?

Also which code line pop up the error message, is the line below?
Table.ApplyLogOnInfo(LogonInfo)

I think you may try to change your code as below to see if the problem
persists, becauses the VB.NET is case-insensitive language.
Dim tbl As Table
Dim logInfo As New TableLogOnInfo
For Each Table In reportDocument.Database.Tables
logInfo = tbl.LogOnInfo
logInfo.ConnectionInfo.ServerName = ConnectString.DataSource
logInfo.ConnectionInfo.DatabaseName = ConnectString.InitialCatalog
tbl.ApplyLogOnInfo(LogonInfo)
Next

Also can you check if you are using the same version of crystal reporter
assembly, i.e. if the CrystalDecisions.CrystalReports.Engine.dll is for
.net framework 1.1 and CrystalDecisions.Shared.dll is for .net frameword
1.0 which may cause the problem.

Here is the setting on my machine, you may check them in the object browser
by pressing Ctrl+Alt+J
Assembly CrystalDecisions.Shared
C:\Program Files\Common Files\Crystal
Decisions\1.1\Managed\CrystalDecisions.Shared.dll
Assembly CrystalDecisions.CrystalReports.Engine
C:\Program Files\Common Files\Crystal
Decisions\1.1\Managed\CrystalDecisions.CrystalReports.Engine.dll

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
R

runningdog

Thanks for a very thoughtful responce Peter.
I'll have a look on Monday and get back to you.

Regards Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top