cancel
Showing results for 
Search instead for 
Did you mean: 

ApplyLogOnInfo and performance

Former Member
0 Kudos

Hi

We have upgraded to CR2013 for Visual Studio 2012 and have a question regarding ApplyLogOnInfo.

Earlier in our code we did this to change logon settings:

            Dim crDatabase As Database

            Dim crTables As Tables

            Dim crTable As Table

            Dim crLogOnInfo As TableLogOnInfo

            Dim crConnInfo As New ConnectionInfo()

            Dim subRepDoc As New ReportDocument()

            Dim crSections As Sections

            Dim crSection As Section

            Dim crReportObjects As ReportObjects

            Dim crReportObject As ReportObject

            Dim crSubreportObject As SubreportObject

            'Set the database and the tables objects to the main report

            crDatabase = crReport.Database

            crTables = crDatabase.Tables

            'Loop through each table and set the connection info

            'Pass the connection info to the logoninfo object then apply the

            'logoninfo to the main report

            For Each crTable In crTables

                With crConnInfo

                    .ServerName = SQLServer

                    .DatabaseName = Databas

                    .UserID = "xxxxx"

                    .Password = "xxxxx"

                End With

                crLogOnInfo = crTable.LogOnInfo

                crLogOnInfo.ConnectionInfo = crConnInfo

                crTable.ApplyLogOnInfo(crLogOnInfo)

                crTable.Location = crTable.Name

            Next

            crSections = crReport.ReportDefinition.Sections

            ''Loop through each section and find all the report objects

            ''Loop through all the report objects to find all subreport objects, then set the

            ''logoninfo to the subreport

            For Each crSection In crSections

                crReportObjects = crSection.ReportObjects

                For Each crReportObject In crReportObjects

                    If crReportObject.Kind = ReportObjectKind.SubreportObject Then

                        'If you find a subreport, typecast the reportobject to a subreport object

                        crSubreportObject = CType(crReportObject, SubreportObject)

                        subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

                        crDatabase = subRepDoc.Database

                        crTables = crDatabase.Tables

                        For Each crTable In crTables

                            With crConnInfo

                                .ServerName = SQLServer

                                .DatabaseName = Databas

                                .DatabaseName = Databas

                                .UserID = "xxxxx"

                                .Password = "xxxx"

                            End With

                            crLogOnInfo = crTable.LogOnInfo

                            crLogOnInfo.ConnectionInfo = crConnInfo

                            crTable.ApplyLogOnInfo(crLogOnInfo)

                            crTable.Location = crTable.Name

                        Next

                    End If

                Next

            Next

Now we have found out that this code also works, we only set ApplyLogOnInfo on the first table:

            Dim crDatabase As Database

            Dim crTables As Tables

            Dim crTable As Table

            Dim crLogOnInfo As TableLogOnInfo

            Dim crConnInfo As New ConnectionInfo()

            Dim subRepDoc As New ReportDocument()

            'Set the database and the tables objects to the main report

            crDatabase = crReport.Database

            crTables = crDatabase.Tables

            crTable = crTables(0)

            With crConnInfo

                .ServerName = SQLServer

                .DatabaseName = Databas

                .UserID = "xxxx"

                .Password = "xxx"

            End With

            crLogOnInfo = crTable.LogOnInfo

            crLogOnInfo.ConnectionInfo = crConnInfo

            crTable.ApplyLogOnInfo(crLogOnInfo)

            crTable.Location = crTable.Name

This code makes the reports display and print faster but we are not sure if this is the right way to do it.

Plz comment on this so we dont deliver something that will stop working for our customers.

Best regards

Kenneth

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Perfect. Nothing wrong there. If you look at the samples here:

http://scn.sap.com/docs/DOC-35744

That is exactly the code used in those samples.

- Ludek

Senior Support Engineer Product Support, Global Support Center Canada

Follow me on Twitter

Got Enhancement ideas? Use the SAP Idea Place

Former Member
0 Kudos

The link is not working:

Not Found

The item does not exist. It may have been deleted.

0 Kudos

Hi Kenneth,

Not found for me either, we'll have to track it down....

As long as the data source is not different for the main and subreport then your new code will work fine.

What you were doing the first time was setting location for each one, because although we don't like it you can actually set the location for each table to different locations. But test i n CRD first and you'll see the warning message.

So as long as the datasource is the same CR will use the connection info you made for the fist table for all other tables.

Don

Former Member
0 Kudos

Ludek I cant find any example in your link that uses our new method only the old one, like this:

            Tables tables = reportDocument.Database.Tables;

            foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)

            {

                TableLogOnInfo tableLogonInfo = table.LogOnInfo;

                tableLogonInfo.ConnectionInfo = connectionInfo;

                table.ApplyLogOnInfo(tableLogonInfo);

            }

Is the answer from Don correct or not?

0 Kudos

If parsing through the whole connection collection fails I suggest checking your report. Something is amiss....

Add crTable.TestConnectivity() on each one to validate they works, just in Debug mode, may not be required at runtime.

Don

Answers (0)