locked
Occasionally getting error while run the rdlcreport RRS feed

  • Question

  •  
    Hi,
            I am working in RDLC report generation.I have created 2 reports and assigned parameters and those two are working fine.But while run the third report occasionally i am getting

    1.An error occurred during local report processing.an error has occurred during local report processing.index outside the bounds of an array.

    and

    2.An error occurred during local report processing.an error has occurred during local report processing.object reference is not set to an instance of an object.

    in my reports i am using 51 parameters to assign the literals from database.and i am adding my code for your reference.

    Option Explicit On

    Option Strict On

    Imports Volvo.ServiceAgreement.Business

    Imports Volvo.ServiceAgreement.Components

    Imports System.Windows.Forms

    Imports Volvo.ServiceAgreement.UI

    Imports System

    Imports System.Drawing

    Imports Microsoft.Reporting.WinForms

    Imports System.Data

    Imports System.Configuration

    Imports System.Web

    Imports System.Web.Security

    Imports System.Web.UI

    Imports System.Web.UI.WebControls

    Imports System.Web.UI.WebControls.WebParts

    Imports System.Web.UI.HtmlControls

    Imports System.Globalization

    Imports System.Threading

    Imports System.Text

    Imports System.IO

    Imports System.Resources

    Imports System.Collections

    Imports System.Xml

    Imports System.Reflection



    Public Class FrmTSA

    Inherits Volvo.ServiceAgreement.UI.BaseTemplateUI

    Dim doc As New XmlDocument()

    Dim node As XmlNode

    Dim nodeName As String

    Dim objServiceFacade As ServiceFacade

    #Region "ErrorConstants"

    Private Const SAM_ERR_RPTUTIL_PRINTREPORT As String = "SAM_ERR_RPTUTIL_PRINTREPORT"

    #End Region



    Dim ParamName As ReportParameter

    Dim Paramfontname As ReportParameter

    Dim Paramfontstyle As ReportParameter

    Dim Paramfontsize As ReportParameter

    Dim ParamNumFontSize As ReportParameter

    Dim objLangMngr As New LanguageManager()

    Dim Paramexpinnextyearval As ReportParameter

    Dim paramexpinnext2yearval As ReportParameter

    Dim str, strexpinnext, strexpinnext2, strparamname, strFontSize, strNumfontSize As String

    Dim dDSvalue As DataSet

    Dim iReportid, i As Integer

    Dim DsAssignLiterals As DataSet

    Dim imonthval As Integer

    Dim iyearval As Integer

    Dim param(51) As ReportParameter

    Public Property DSvalue() As DataSet

    Get

    Return dDSvalue

    End Get

    Set(ByVal Value As DataSet)

    dDSvalue = Value

    End Set

    End Property

    Public Property Reportid() As Integer

    Get

    Return iReportid

    End Get

    Set(ByVal value As Integer)

    iReportid = value

    End Set

    End Property

    Private Sub FrmTSA_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Try

    objServiceFacade = CType(Factory.Create(GetType(ServiceFacade), _

    Factory.BUSINESSFACADE_INSTANCENAME), ServiceFacade)

    strFontSize = CStr(objServiceFacade.ReportFontSize).ToString()

    strNumfontSize = CStr(objServiceFacade.ReportNumberFontSize).ToString()

    Me.BringToFront()

    ReportViewer1.Show()

    'TableBindingSource.DataSource = DSvalue

    Me.ReportViewer1.RefreshReport()

    ReportViewer1.Show()

    ReportViewer1.Visible = True

    Me.BringToFront()





    If Month(Date.Now) = 1 Then

    imonthval = 12

    iyearval = Year(Date.Now) - 1

    Else

    imonthval = Month(Date.Now) - 1

    iyearval = Year(Date.Now)

    End If

    If Reportid = 31 Then

    Paramfontname = New ReportParameter("ParamFontName", objServiceFacade.ReportFontName)

    Paramfontstyle = New ReportParameter("ParamFontStyle", "Normal")

    Paramfontsize = New ReportParameter("ParamFontSize", strFontSize)

    ParamNumFontSize = New ReportParameter("ParamNumFontSize", strNumfontSize)



    Dim rds As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    rds.Name = "DsCostOverview_Table"

    rds.Value = DSvalue.Tables(0)

    'load report

    ReportViewer1.Reset()

    ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local

    ReportViewer1.LocalReport.DataSources.Clear()

    ReportViewer1.LocalReport.ReportEmbeddedResource = ".TSACostOverview.rdlc"

    ReportViewer1.LocalReport.ReportPath = "C:\SAM\SourceCode\Solution\ReportUtil\TSACostOverView.rdlc"



    ReportViewer1.LocalReport.DataSources.Add(rds)

    DsAssignLiterals = objLangMngr.TSAGetliterals(CurrentLanguage, Reportid)

    For i = 0 To DsAssignLiterals.Tables(0).Rows.Count - 1

    strparamname = "Param" + i.ToString()

    ParamName = New ReportParameter(strparamname, DsAssignLiterals.Tables(0).Rows(i).Item("STRLITERAL").ToString())

    ReportViewer1.LocalReport.SetParameters(New ReportParameter() {ParamName})

    Next

    ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Paramfontname, Paramfontstyle, Paramfontsize, ParamNumFontSize})

    ElseIf Reportid = 30 Then

    Paramfontname = New ReportParameter("ParamFontName", objServiceFacade.ReportFontName)

    Paramfontstyle = New ReportParameter("ParamFontStyle", "Normal")

    Paramfontsize = New ReportParameter("ParamFontSize", strFontSize)

    ParamNumFontSize = New ReportParameter("ParamNumFontSize", strNumfontSize)

    Dim rdsAnalysisDlr As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdsContract As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    rdsAnalysisDlr.Name = "DSAnalysisSA_Table"

    rdsAnalysisDlr.Value = DSvalue.Tables(0)

    rdsContract.Name = "DSAnalysisSA_Table1"

    rdsContract.Value = DSvalue.Tables(1)

    ReportViewer1.Reset()

    ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local

    ReportViewer1.LocalReport.DataSources.Clear()

    ReportViewer1.LocalReport.ReportEmbeddedResource = ".TSAAnalysisSAPerContract.rdlc"

    ReportViewer1.LocalReport.ReportPath = "C:\SAM\SourceCode\Solution\ReportUtil\TSAAnalysisSAPerContract.rdlc"

    DsAssignLiterals = objLangMngr.TSAGetliterals(CurrentLanguage, Reportid)

    For i = 0 To DsAssignLiterals.Tables(0).Rows.Count - 1

    strparamname = "Param" + i.ToString()

    ParamName = New ReportParameter(strparamname, DsAssignLiterals.Tables(0).Rows(i).Item("STRLITERAL").ToString())

    ReportViewer1.LocalReport.SetParameters(New ReportParameter() {ParamName})

    Next

    ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Paramfontname, Paramfontstyle, Paramfontsize, ParamNumFontSize})

    ReportViewer1.LocalReport.DataSources.Add(rdsAnalysisDlr)

    ReportViewer1.LocalReport.DataSources.Add(rdsContract)

    ElseIf Reportid = 32 Then

    Dim rdslast12months As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdsbudgetcostrev As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdsrunningsa As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdsrunsaexpincurr As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdsrunsaexpinnext As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdsrunsaexpinnext2 As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdsrunsaexpafternext2 As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdsexpsa As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdsexpsaincurr As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdsexpsabeforecurr As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdsclosedQ1 As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdsclosedQ12 As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdsclosedQ13 As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdsclosedQ14 As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()



    Dim rdscurryear As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdsbeforecurryear As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    Dim rdscurryeartodate As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()



    Dim rdsnbrofsa As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()

    If DSvalue.Tables.Count = 18 Then

    If DSvalue.Tables(0).Columns.Count > 0 And DSvalue.Tables(1).Columns.Count > 0 And DSvalue.Tables(2).Columns.Count > 0 And DSvalue.Tables(3).Columns.Count > 0 And DSvalue.Tables(4).Columns.Count > 0 And DSvalue.Tables(5).Columns.Count > 0 And DSvalue.Tables(6).Columns.Count > 0 And DSvalue.Tables(7).Columns.Count > 0 And DSvalue.Tables(8).Columns.Count > 0 And DSvalue.Tables(9).Columns.Count > 0 And DSvalue.Tables(10).Columns.Count > 0 And DSvalue.Tables(11).Columns.Count > 0 And DSvalue.Tables(12).Columns.Count > 0 And DSvalue.Tables(13).Columns.Count > 0 And DSvalue.Tables(14).Columns.Count > 0 And DSvalue.Tables(15).Columns.Count > 0 And DSvalue.Tables(16).Columns.Count > 0 And DSvalue.Tables(17).Columns.Count > 0 Then

    Try

    rdslast12months.Name = "DSMgmtRptSAPerMarket_Table"

    rdslast12months.Value = DSvalue.Tables(16)



    rdsbudgetcostrev.Name = "DSMgmtRptSAPerMarket_Table1"

    rdsbudgetcostrev.Value = DSvalue.Tables(17)



    rdsrunningsa.Name = "DSMgmtRptSAPerMarket_Table2"

    rdsrunningsa.Value = DSvalue.Tables(0)



    rdsrunsaexpincurr.Name = "DSMgmtRptSAPerMarket_Table3"

    rdsrunsaexpincurr.Value = DSvalue.Tables(3)



    rdsrunsaexpinnext.Name = "DSMgmtRptSAPerMarket_Table4"

    rdsrunsaexpinnext.Value = DSvalue.Tables(4)

    rdsrunsaexpinnext2.Name = "DSMgmtRptSAPerMarket_Table5"

    rdsrunsaexpinnext2.Value = DSvalue.Tables(5)

    rdsrunsaexpafternext2.Name = "DSMgmtRptSAPerMarket_Table6"

    rdsrunsaexpafternext2.Value = DSvalue.Tables(6)

    rdsexpsa.Name = "DSMgmtRptSAPerMarket_Table7"

    rdsexpsa.Value = DSvalue.Tables(1)



    rdsexpsaincurr.Name = "DSMgmtRptSAPerMarket_Table8"

    rdsexpsaincurr.Value = DSvalue.Tables(7)



    rdsexpsabeforecurr.Name = "DSMgmtRptSAPerMarket_Table9"

    rdsexpsabeforecurr.Value = DSvalue.Tables(8)

    rdsclosedQ1.Name = "DSMgmtRptSAPerMarket_Table10"

    rdsclosedQ1.Value = DSvalue.Tables(2)

    rdsclosedQ12.Name = "DSMgmtRptSAPerMarket_Table11"

    rdsclosedQ12.Value = DSvalue.Tables(9)

    rdsclosedQ13.Name = "DSMgmtRptSAPerMarket_Table12"

    rdsclosedQ13.Value = DSvalue.Tables(10)

    rdsclosedQ14.Name = "DSMgmtRptSAPerMarket_Table13"

    rdsclosedQ14.Value = DSvalue.Tables(11)

    rdscurryear.Name = "DSMgmtRptSAPerMarket_Table14"

    rdscurryear.Value = DSvalue.Tables(12)

    rdsbeforecurryear.Name = "DSMgmtRptSAPerMarket_Table15"

    rdsbeforecurryear.Value = DSvalue.Tables(13)

    rdscurryeartodate.Name = "DSMgmtRptSAPerMarket_Table16"

    rdscurryeartodate.Value = DSvalue.Tables(14)

    rdsnbrofsa.Name = "DSMgmtRptSAPerMarket_Table17"

    rdsnbrofsa.Value = DSvalue.Tables(15)

    ReportViewer1.Reset()

    ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local

    ReportViewer1.LocalReport.DataSources.Clear()


    ReportViewer1.LocalReport.ReportEmbeddedResource = ".TSAMgmtRptSerContractPerMarket.rdlc"

    ReportViewer1.LocalReport.ReportPath = "C:\SAM\SourceCode\Solution\ReportUtil\TSAMgmtRptSerContractPerMarket.rdlc"






    ReportViewer1.LocalReport.DataSources.Add(rdslast12months)

    ReportViewer1.LocalReport.DataSources.Add(rdsbudgetcostrev)

    ReportViewer1.LocalReport.DataSources.Add(rdsrunningsa)

    ReportViewer1.LocalReport.DataSources.Add(rdsrunsaexpincurr)

    ReportViewer1.LocalReport.DataSources.Add(rdsrunsaexpinnext)

    ReportViewer1.LocalReport.DataSources.Add(rdsrunsaexpinnext2)

    ReportViewer1.LocalReport.DataSources.Add(rdsrunsaexpafternext2)

    ReportViewer1.LocalReport.DataSources.Add(rdsexpsa)

    ReportViewer1.LocalReport.DataSources.Add(rdsexpsaincurr)

    ReportViewer1.LocalReport.DataSources.Add(rdsexpsabeforecurr)

    ReportViewer1.LocalReport.DataSources.Add(rdsclosedQ1)

    ReportViewer1.LocalReport.DataSources.Add(rdsclosedQ12)

    ReportViewer1.LocalReport.DataSources.Add(rdsclosedQ13)

    ReportViewer1.LocalReport.DataSources.Add(rdsclosedQ14)



    ReportViewer1.LocalReport.DataSources.Add(rdscurryear)

    ReportViewer1.LocalReport.DataSources.Add(rdsbeforecurryear)

    ReportViewer1.LocalReport.DataSources.Add(rdscurryeartodate)

    ReportViewer1.LocalReport.DataSources.Add(rdsnbrofsa)

    DsAssignLiterals = objLangMngr.TSAGetliterals(CurrentLanguage, Reportid)

    strexpinnext = DsAssignLiterals.Tables(0).Rows(1).Item("STRLITERAL").ToString() + " Y" + ((Year(Date.Now) + 1).ToString())

    strexpinnext2 = DsAssignLiterals.Tables(0).Rows(1).Item("STRLITERAL").ToString() + " Y" + ((Year(Date.Now) + 2).ToString())

    Paramexpinnextyearval = New ReportParameter()

    Paramexpinnextyearval.Name = "Paramexpinnextyear"

    Paramexpinnextyearval.Values.Add(strexpinnext)

    paramexpinnext2yearval = New ReportParameter()

    paramexpinnext2yearval.Name = "paramexpinnext2year"

    paramexpinnext2yearval.Values.Add(strexpinnext2)

    For i = 0 To DsAssignLiterals.Tables(0).Rows.Count - 1

    If Not DsAssignLiterals.Tables(0).Rows(i).Item("STRLITERAL") Is Nothing Then

    strparamname = "Param" + i.ToString()

    str = DsAssignLiterals.Tables(0).Rows(i).Item("STRLITERAL").ToString()

    If strparamname = "Param1" Or strparamname = "Param19" Or strparamname = "Param20" Or strparamname = "Param26" Or strparamname = "Param43" Then

    str = str + " Y" + Year(Date.Now).ToString()

    ElseIf strparamname = "Param2" Then

     str = str + " Y" + ((Year(Date.Now) + 2).ToString())

    ElseIf strparamname = "Param27" Or strparamname = "Param28" Or strparamname = "Param39" Or strparamname = "Param40" Or strparamname = "Param41" Or strparamname = "Param42" Then

     str = str + " Y" + CStr(iyearval).ToString() + "/" + CStr(imonthval).ToString()

    End If

    ParamName = New ReportParameter(strparamname, str)

    ReportViewer1.LocalReport.SetParameters(New ReportParameter() {ParamName})

    Else

    Exit Sub

    End If

    Next

    ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Paramexpinnextyearval, paramexpinnext2yearval})


    Catch objException As ExceptionHandler

    Throw objException

    Catch objException As Exception

    Throw New ExceptionHandler(SAM_ERR_RPTUTIL_PRINTREPORT, objException)

    End Try

    Else

    Exit Sub

    End If

    End If



    End If

    ReportViewer1.RefreshReport()

    ReportViewer1.Visible = True

    ReportViewer1.Show()

    Me.BringToFront()

    Catch objException As ExceptionHandler

    Throw objException

    Catch objException As Exception

    Throw New ExceptionHandler(SAM_ERR_RPTUTIL_PRINTREPORT, objException)

    End Try

    End Sub

    i have checked with dataset values.always it is showing the values correctly.



    I have tried with many ways.But still it is giving the error.How to get rid from this error?what is the reason for this error?i am using same type of code for other two reports.but in third reports after getting the value from database i am concatenate that value with some value and assigned to parameter?is it because of that?i have commented that concatenation code and checked.Still it is showing that error?Please help me to get rid of this.
    Tuesday, December 9, 2008 9:50 AM

Answers

All replies