Skip to Content
avatar image
Former Member

ApplyLogOnInfo not working

Hello,

We are trying to use ApplyLogOnInfo to dynamically pass Sybase database login credentials to load/export data into a .rpt file. However, it doesn't seem to be doing anything when calling the function.

We are using Microsoft Visual Basic 2015 with SAP BusinessObjects Enterprise XI 4.0. Below is a portion of the code:

Imports CrystalDecisions.Reporting
Imports System.IO
Imports System.Data.Odbc
Imports System.Data
Imports System.Configuration
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.ReportAppServer.DataDefModel

Module Module1

    Sub Main()
        'get command line arguments
        Dim CommandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String) = My.Application.CommandLineArgs

        Dim myConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo()
        With myConnectionInfo
            .ServerName = CommandLineArgs(5)
            .DatabaseName = CommandLineArgs(7)
            .UserID = CommandLineArgs(9)
            .Password = CommandLineArgs(11)
        End With

        Dim cryRpt As New ReportDocument
        cryRpt.Load(CommandLineArgs(3))
        cryRpt.SetDatabaseLogon(myConnectionInfo.UserID, myConnectionInfo.Password, myConnectionInfo.ServerName, myConnectionInfo.DatabaseName)

        Dim crTables As CrystalDecisions.CrystalReports.Engine.Tables = cryRpt.Database.Tables

        For Each crTable As CrystalDecisions.CrystalReports.Engine.Table In crTables
            Dim crTableLogonInfo As New TableLogOnInfo()
            crTableLogonInfo = crTable.LogOnInfo
            crTableLogonInfo.ReportName = cryRpt.Name
            crTableLogonInfo.ConnectionInfo.AllowCustomConnection = True
            crTableLogonInfo.ConnectionInfo = myConnectionInfo
            crTableLogonInfo.TableName = crTable.Name
            MessageBox.Show(crTableLogonInfo.ConnectionInfo.ServerName)
            MessageBox.Show(crTableLogonInfo.ConnectionInfo.DatabaseName)
            MessageBox.Show(crTableLogonInfo.ConnectionInfo.UserID)
            MessageBox.Show(crTableLogonInfo.ConnectionInfo.Password)
            crTable.ApplyLogOnInfo(crTableLogonInfo)
            MessageBox.Show(crTable.LogOnInfo.ConnectionInfo.ServerName)
            MessageBox.Show(crTable.LogOnInfo.ConnectionInfo.DatabaseName)
            MessageBox.Show(crTable.LogOnInfo.ConnectionInfo.UserID)
            MessageBox.Show(crTable.LogOnInfo.ConnectionInfo.Password)
            If Not crTable.TestConnectivity() Then
                MessageBox.Show("Failed to apply log in")
            End If
        Next

The message boxes were added during troubleshooting which showed that the login credentials for the table did not update to the supplied values. Instead, it showed the details of the database that was used during the development of the .rpt file.

We've searched previously asked questions about the ApplyLogOnInfo function, but have not found any solutions.

Any help is greatly appreciated!

P.S. - Apologies in advance if there isn't enough information provided.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Feb 07 at 07:25 PM

    Changed Tag to BOE Platform SDK.

    Makes sure the .NET SDK you are using is the same version of BOE Server.

    And BOE 4.0 is end of patch cycle now, time to upgrade to 4.2

    Don

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Don,

      Appreciate the quick response.

      From what I can tell, the BOE server version is 14.1.7.1853 2013 Support Pack 7. The .NET SDK as referenced by VB shows v13.

      Is there a v14 .NET SDK for Crystal Reports? I wasn't able to find anything higher than 13.

      Thanks,

      Chris

      wogtw.png (5.8 kB)
  • Feb 28 at 06:45 PM

    OK, the Version 13 assemblies will not connect to BOE now. You can uninstall them.

    You need to go to SMP and download the BOE .NET SDK.

    Requires a support contract to get there and a USer account to log in.

    Don

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 28 at 06:56 PM

    Hi Chris,
    do your messageboxes show the same info before and after applyLogonInfo or are they different values before and after?

    Does the logon fail?

    Even though your messageboxes show connectioninfo saved in the report, if you do successfully log on with this code is the data displayed for the old database or is it from the new connection?

    I don't see anything glaringly wrong with the code, but you are logging on twice, which is unecessary.

    SetDatabaseLogon will log on to the DB as well as logging onto each individual table. Both methods are not necessary. SetDatabaseLogon is more of a helper method to simplify the logon. Use only one of the two methods.

    Start by commenting out the "For Each..." loop. Does the report logon and display correct data?

    If you want to use TableLogonInfo, comment out the line using SetDabaseLogon and see if this works.

    There is a V14 .NET sdk. The 32bit assemblies install (as an option) with the BOE client install. The 64bit assemblies install (as an option) with the BOE server install. If you have BOE, then the runtimes can also be downloaded from https://support.sap.com/en/my-support/software-downloads.html
    The V14 SDK includes runtime for BOE as well so it is much larger than the V13 install. Since you are using the ReportDocument object model and you are not connecting to BOE, there is no advantage to using the V14 runtime.

    Dan

    Add comment
    10|10000 characters needed characters exceeded