Writing Code
 Crystal Reports Forum : Crystal Reports .NET 2003 : Writing Code
Message Icon Topic: Please Help! BUG.... Post Reply Post New Topic
Author Message
angelyin1984
Newbie
Newbie
Avatar

Joined: 08 May 2009
Location: Malaysia
Online Status: Offline
Posts: 30
Quote angelyin1984 Replybullet Topic: Please Help! BUG....
    Posted: 02 Jun 2009 at 6:34pm

Server Error in '/movexreport_1' Application.

Object variable or With block variable not set.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object variable or With block variable not set.

Source Error:
Line 168:        fDiscreteValue.Value = Session("Year")
Line 169:        fParameterValues.Add(fDiscreteValue)
Line 170:        crReportDocument.DataDefinition.ParameterFields("Year").ApplyCurrentValues(fParameterValues)
Line 171:
Line 172:        'division
 
Source File: c:\inetpub\wwwroot\movexreport_1\pc\top20supplier_IndividualSubsidary.ascx.vb    Line: 170

Stack Trace:
[NullReferenceException: Object variable or With block variable not set.]
   Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack) +928
   movexreport.top20supplier_IndividualSubsidary1.initParam() in c:\inetpub\wwwroot\movexreport_1\pc\top20supplier_IndividualSubsidary.ascx.vb:170
   movexreport.top20supplier_IndividualSubsidary1.cmdGenerate_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\movexreport_1\pc\top20supplier_IndividualSubsidary.ascx.vb:52
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain() +1292
 
P/S: this is an error
 
---------------------------------------------------------------------------------------------

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

Imports mvx_rpt.data_access

Imports mvx_rpt._date

Imports mvx_rpt.session

Public MustInherit Class top20supplier_IndividualSubsidary1

Inherits System.Web.UI.UserControl

Protected WithEvents lblReportTitle As System.Web.UI.WebControls.Label

Protected WithEvents cmdExport As System.Web.UI.WebControls.Button

Protected WithEvents lbldivision As System.Web.UI.WebControls.Label

Protected WithEvents ddldivision As System.Web.UI.WebControls.DropDownList

Protected WithEvents lblYear As System.Web.UI.WebControls.Label

Protected WithEvents ddlYear As System.Web.UI.WebControls.DropDownList

Protected WithEvents lblMonth As System.Web.UI.WebControls.Label

Protected WithEvents ddlMonth As System.Web.UI.WebControls.DropDownList

Protected WithEvents lblSorting As System.Web.UI.WebControls.Label

Protected WithEvents ddlSorting As System.Web.UI.WebControls.DropDownList

Protected WithEvents CrystalReportViewer As CrystalDecisions.Web.CrystalReportViewer

Protected WithEvents cmdGenerate As System.Web.UI.WebControls.Button

Protected WithEvents ctlExport As ctlExport

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

#Region " Subs and Functions "

Public FCharmonth As Integer

Public TCharmonth As Integer

Public CharMonth As Integer

Public Charyear As Integer

Public MonthDesc As Integer

Private Sub initDivision()

Dim fDataReader As SqlClient.SqlDataReader

Dim fParam(1) As SqlClient.SqlParameter

fParam(0) = New SqlClient.SqlParameter("@username", SqlDbType.VarChar, 255, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Proposed, Session("User"))

fParam(1) = New SqlClient.SqlParameter("@module", SqlDbType.VarChar, 255, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Proposed, UCase(Left(Request.QueryString("opt"), 2)))

initConn(1)

fDataReader = initCommand("mvxRPT_GetDivision", 1, 4, fParam)

ddldivision.DataSource = fDataReader

ddldivision.DataTextField = "Description"

ddldivision.DataValueField = "Division"

ddldivision.DataBind()

closeCommand(fDataReader)

closeConn()

End Sub

Private Sub initYearMonth()

Dim fDataReader As SqlClient.SqlDataReader

Dim ftype As Integer

ftype = 5

'Invoice Year

initConn(ftype)

fDataReader = initCommand("SELECT DISTINCT [Rec_Year] as Year FROM view_PurchaseReport_L4 ORDER BY [Rec_Year]", 1, 1)

ddlYear.DataSource = fDataReader

ddlYear.DataTextField = "Year"

ddlYear.DataValueField = "Year"

ddlYear.DataBind()

closeCommand(fDataReader)

closeConn()

ddlYear.SelectedIndex = ddlYear.Items.Count - 1

End Sub

Private Sub setGUI(ByVal pVisible As Boolean)

'Label

lblYear.Visible = pVisible

lblMonth.Visible = pVisible

lbldivision.Visible = pVisible

lblSorting.Visible = pVisible

'Object

ddlYear.Visible = pVisible

ddlMonth.Visible = pVisible

ddldivision.Visible = pVisible

ddlSorting.Visible = pVisible

cmdGenerate.Visible = pVisible

CrystalReportViewer.Visible = Not pVisible

ctlExport.Visible = Not pVisible

cmdExport.Visible = Not pVisible

End Sub

Private Sub initReport()

Dim crConnectionInfo As ConnectionInfo

Dim crDatabase As Database

Dim crTables As Tables

Dim crTable As Table

Dim crTableLogonInfo As TableLogOnInfo

'Setup the connection information structure to be used to log onto the datasource for the report.

crConnectionInfo = New ConnectionInfo()

With crConnectionInfo

.ServerName = ConfigurationSettings.AppSettings("BPW_LIVE_ODBC") 'Session("Environment") 'physical server name

.DatabaseName = ConfigurationSettings.AppSettings("BPW_LIVE_DB") '"S65B0ABF." & Session("Environment") 'database name

.UserID = ConfigurationSettings.AppSettings("BPW_UID") 'username

.Password = ConfigurationSettings.AppSettings("BPW_PWD")

End With

If ddlSorting.SelectedItem.Value = 1 Then

crReportDocument = New Top20Supplier_IndividualSubsidary()

Else

'If ddlSorting.SelectedItem.Value = 2 Then

crReportDocument = New Top20Supplier_IndividualSubsidary_MTD()

'End If

End If

crDatabase = crReportDocument.Database

crTables = crDatabase.Tables

'Loop through all tables in the report and apply the connection information for each table.

For Each crTable In crTables

crTableLogonInfo = crTable.LogOnInfo

crTableLogonInfo.ConnectionInfo = crConnectionInfo

crTable.ApplyLogOnInfo(crTableLogonInfo)

Next

'crReportDocument.datadefinition.Recordselectionformula = "{FT_KJCF_IntLocalOverseaSales_Ver1.Company}=666 and {FT_KJCF_IntLocalOverseaSales_Ver1.Year} =2005 and {FT_KJCF_IntLocalOverseaSales_Ver1.MonthDesc} ='December'"

CrystalReportViewer.ReportSource = crReportDocument

CrystalReportViewer.Visible = True

End Sub

Private Sub initParam()

'apply parameter to crystal report

Dim StrQry As String

Dim fParameterValues As New ParameterValues()

Dim fDiscreteValue As New ParameterDiscreteValue()

'Year

'fDiscreteValue.Value = Session("ZZPGRN.ICPUNO.YEAR")

fDiscreteValue.Value = Session("Year")

fParameterValues.Add(fDiscreteValue)

crReportDocument.DataDefinition.ParameterFields("Year").ApplyCurrentValues(fParameterValues)

'division

fDiscreteValue.Value = Session("division")

fParameterValues.Add(fDiscreteValue)

crReportDocument.DataDefinition.ParameterFields("division").ApplyCurrentValues(fParameterValues)

'From Month

'fDiscreteValue.Value = Session("ZZPGRN.ICPUNO.MONTH")

fDiscreteValue.Value = Session("Month")

fParameterValues.Add(fDiscreteValue)

crReportDocument.DataDefinition.ParameterFields("Month").ApplyCurrentValues(fParameterValues)

If ddlSorting.SelectedItem.Value = 1 Then

'Sorting Option

fDiscreteValue.Value = Session("Sorting")

fParameterValues.Add(fDiscreteValue)

crReportDocument.DataDefinition.ParameterFields("SortBy").ApplyCurrentValues(fParameterValues)

Else

fDiscreteValue.Value = Session("User")

fParameterValues.Add(fDiscreteValue)

crReportDocument.DataDefinition.ParameterFields("UserID").ApplyCurrentValues(fParameterValues)

End If

End Sub

Private Sub setParam()

'set parameter to session and retrieve it later

'Session("ZZPGRN.ICPUNO.YEAR") = ddlYear.SelectedItem.Value

Session("Year") = ddlYear.SelectedItem.Value

Session("division") = ddldivision.SelectedItem.Value

'Session("ZZPGRN.ICPUNO.MONTH") = ddlMonth.SelectedItem.Value

Session("Month") = ddlMonth.SelectedItem.Value

Session("Sorting") = ddlSorting.SelectedItem.Value

End Sub

Function MonthChar(ByVal MonthDesc)

Select Case MonthDesc

Case Is = "January"

CharMonth = 1

Case Is = "February"

CharMonth = 2

Case Is = "March"

CharMonth = 3

Case Is = "April"

CharMonth = 4

Case Is = "May"

CharMonth = 5

Case Is = "June"

CharMonth = 6

Case Is = "July"

CharMonth = 7

Case Is = "August"

CharMonth = 8

Case Is = "September"

CharMonth = 9

Case Is = "October"

CharMonth = 10

Case Is = "November"

CharMonth = 11

Case Is = "December"

CharMonth = 12

End Select

End Function

Private Sub exportFile()

'export output to excel, doc or pdf

Dim fFileName As String = mvx_rpt.report.exportFile(crReportDocument, CStr(Request.QueryString("opt")), ctlExport.ExportFormat, Session("User"))

Response.Redirect("./export/" & fFileName)

End Sub

 

#End Region

End Class

P/S: this is the vb.net coding
---------------------------------------------------------------------------------------------
 
I not sure how to solve the problem, please advise.
thanks in advance.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.