Quantcast
Channel: SCN : Discussion List - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 3636

ApplyLogOnInfo and performance

$
0
0

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


Viewing all articles
Browse latest Browse all 3636

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>