Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can't Set Params
Message
Information générale
Forum:
ASP.NET
Catégorie:
Rapports
Titre:
Can't Set Params
Divers
Thread ID:
01127122
Message ID:
01127122
Vues:
47
I have this CR Reports that work fine on My desktop server pointing to our dev sql server.
The report has three subreports. Main and subs were setup to pull data using sql sps. When we move this to our dev web server that points to the same sql sever, all works well. When we move to our production server that points to a different sql server it fails when the code behind passes in the param for the first sub report. Indicating that the array is out of bounds. I've gone thru the process of coding the ApplyLogon to the main and all subs. I've tryed setting params befoe and after. Can someone point me to the decoder ring that will allow this to work?
Logon(crReportDocument, ServerName, DatabaseName, UserID, Password)

crReportDocument.SetParameterValue("@MYID", id) 'SQL SP Main
crReportDocument.SetParameterValue("@MYID", id, "SUB1") 'SQL SP SUB1
crReportDocument.SetParameterValue("@MYID", id, "SUB2") 'SQL SP SUB2        crReportDocument.SetParameterValue("@MYID", id, "SUB3") 'SQL SP SUB3

CrystalReportViewer1.ReportSource = crReportDocument
CrystalReportViewer1.Visible = True

Private Function ApplyLogon(ByVal cr As CrystalDecisions.CrystalReports.Engine.ReportDocument, ByVal ci As CrystalDecisions.Shared.ConnectionInfo) As Boolean
        ' This function is called by the "Logon" function
        ' It loops through the report tables and applies
        ' the connection information to each table.

        ' Declare the TableLogOnInfo object and a table object for use later.
        Dim li As CrystalDecisions.Shared.TableLogOnInfo
        Dim tbl As CrystalDecisions.CrystalReports.Engine.Table

        ' For each table apply connection info.
        For Each tbl In cr.Database.Tables
            li = tbl.LogOnInfo
            li.ConnectionInfo = ci
            tbl.ApplyLogOnInfo(li)

            ' Verify that the logon was successful.
            ' If TestConnectivity returns false, correct table locations.
            If (tbl.TestConnectivity()) Then
                ' If there is a "." in the location then remove the
                ' beginning of the fully qualified location.
                ' Example "dbo.northwind.customers" would become
                ' "customers".
                If (tbl.Location.IndexOf(".") > 0) Then
                    tbl.Location = tbl.Location.Substring(tbl.Location.LastIndexOf(".") + 1)
                Else
                    ' If the location is not returning as a fully
                    ' qualified location we still set it to tbl.location
                    ' because Crystal Reports 9 installed on top of .NET
                    ' can *store* fully qualified names but will only *return*
                    ' the table name itself.
                    tbl.Location = tbl.Location
                End If
            Else
                Return False
            End If
        Next

        Return True
    End Function

    ' The Logon method iterates through all tables.
    Private Function Logon(ByVal cr As CrystalDecisions.CrystalReports.Engine.ReportDocument, _
        ByVal server As String, _
        ByVal database As String, _
        ByVal user_id As String, _
        ByVal password As String) As Boolean

        ' Declare and populate a new connection info object.
        Dim ci As New CrystalDecisions.Shared.ConnectionInfo()
        With ci
            .ServerName = server
            .DatabaseName = database
            .UserID = user_id
            .Password = password
        End With

        ' If the ApplyLogon function fails then return a false for this function.
        ' We are applying logon information to the main report at this stage.
        If (Not ApplyLogon(cr, ci)) Then
            Return False
        End If

        ' Declare both a report object as well as a subreport object.
        Dim obj As CrystalDecisions.CrystalReports.Engine.ReportObject
        Dim subobj As CrystalDecisions.CrystalReports.Engine.SubreportObject

        ' Loop through all the report objects and locate subreports.
        ' If a subreport is found then apply logon information to
        ' the subreport.
        For Each obj In cr.ReportDefinition.ReportObjects
            If (obj.Kind = CrystalDecisions.[Shared].ReportObjectKind.SubreportObject) Then
                subobj = CType(obj, CrystalDecisions.CrystalReports.Engine.SubreportObject)
                If (Not ApplyLogon(cr.OpenSubreport(subobj.SubreportName), ci)) Then
                    Return False
                End If
            End If
        Next

        ' Return True if the code runs to this stage.
        Return True

    End Function

It's Time to get a gun.

That's what I've been thinkin.

I think I can afford one, If I do a little less Drinkin.

www.TrueGeeks.com
Répondre
Fil
Voir

Click here to load this message in the networking platform