Skip to Content

Problems while migrating from RDC to .Net

I'm using VB.Net 2010 with CR 2008 SP3 to rewrite our library (Interop COM Class...)

I have two major problems:

first, while changing the table logon infos; I can't find the correct way (1st try vs. 2nd try) to update them. This sample tries to change a template MS-SQL table "xTableTest" to "##TableTest123456":

For Each checkTable As CrystalDecisions.CrystalReports.Engine.Table In crystalReportDocument.Database.Tables
    With checkTable
        If .Location.ToUpper.Substring(0, 2) = "XT" Then
            ' change SQL temporary table
            newDatabase = .LogOnInfo.ConnectionInfo.DatabaseName
            newTable = "tempdb.dbo.##" & .Location.Substring(1) & uniqueValue
        End If

        ' 1st try
        With checkTable.LogOnInfo.ConnectionInfo.LogonProperties
            .LookupNameValuePair("Data Source").Value = serverName
            .LookupNameValuePair("Initial Catalog").Value = newDatabase
            .LookupNameValuePair("Connect Timeout").Value = 300
        End With
        With .LogOnInfo.ConnectionInfo
            .ServerName = serverName
            .DatabaseName = newDatabase                        
            .UserID = "User"
            .Password = "pwd"
            .IntegratedSecurity = False
        End With
        .Location = newTable

        ' 2nd try
        Dim newTableLogoninfo As New CrystalDecisions.Shared.TableLogOnInfo
        newTableLogoninfo = .LogOnInfo ' or .LogOnInfo.Clone
        With newTableLogoninfo
            With newTableLogoninfo.ConnectionInfo
                .ServerName = serverName
                .DatabaseName = newDatabase                            
                .UserID = "User"
                .Password = "pwd"
                .IntegratedSecurity = False
            End With
            .TableName = newTable
        End With
        .ApplyLogOnInfo(newTableLogoninfo)

        If Not .TestConnectivity Then                        
            Exit For
        End If
   End With
Next

the first try returns on " .Location = newTable" the following error:

Logon failed. Details: [Database Vendor Code: 18456 ] Error in File Test_L1 {2FFD3972-1D55-41D7-AAD2-FC06400E2F29}.rpt: Unable to connect: incorrect log on parameters.

The second try sometimes works (TestConnectivity), but when the whole code runs, the .ApplyLogOnInfo() resets orginal values of .LogOnInfo.ConnectionInfo ! And how can I set the LogonProperties through the ApplyLogOnInfo() method?

Second problem:

When I call the PrintToPrinter()-method, it returns Invalid report file path. The Load-method before worked without any problems.

Any ideas,

Patrick

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.