I get an itermittant problem with our web page that occurs about once
every 10 to 15 days where the only way to fix the problem is to bounce
the web server. The error can be seen below.
I have looked at the stack trace and determined where the error is
occuring but when I look at my code, where it says that I have an
unhandled exception, I have error handling to handle it. You can see
the code below the error message.
What could be casuing this intermittant behaviour.
Thanks
James
*************** *************** *************** *************** *************** *
*************** *******ERROR
MESSAGE******** *************** *************** ***
*************** *************** *************** *************** *************** *
Server Error in '/' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
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.NullRefe renceException: Object reference not
set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceEx ception: Object reference not set to an instance of an
object.]
login.AccountAc cess.Page_Load( Object sender, EventArgs e) +7514
System.Web.UI.C ontrol.OnLoad(E ventArgs e) +67
System.Web.UI.C ontrol.LoadRecu rsive() +35
System.Web.UI.P age.ProcessRequ estMain() +750
*************** *************** *************** *************** ***************
*************** CODE*********** *************** *************** ***************
*************** *************** *************** *************** ***************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim PremNo, CustNo, FirstName, MiddleName, LastName As String
Dim StreetName, StreetNumber, PostDirection, PreDirection,
ZipCode, State, Unit, UnitNumber, Suffix, City As String
Dim AmountDue, DueDate, PayByCheck As String
Try
'control page caching so
'that page is not cached
Response.Buffer = True
Response.Expire s = 0
Response.Expire sAbsolute = Now.AddDays(-1)
Response.CacheC ontrol = "no-cache"
If (Not IsPostBack) Then
'************** *************** *************
'****** Fill data in dataset **************
'************** *************** *************
Try
'Get Balance Information
Me.daBalance.Se lectCommand.Par ameters("PremNo ").Value
= Session("PremNo ")
Me.daBalance.Se lectCommand.Par ameters("CustNo ").Value
= Session("CustNo ")
Me.daBalance.Fi ll(dsUserData)
Catch ex As Exception
Throw New Exception("Quer y Balance Information: "
& ex.InnerExcepti on.Message & " " & ex.Message)
End Try
Try
'Get the due date
Me.daDueDate.Se lectCommand.Par ameters("PremNo ").Value
= Session("PremNo ")
Me.daDueDate.Se lectCommand.Par ameters("CustNo ").Value
= Session("CustNo ")
Me.daDueDate.Fi ll(dsUserData)
Catch ex As Exception
Throw New Exception("Quer y Due Date: " &
ex.InnerExcepti on.Message & " " & ex.Message)
End Try
Try
'Get Account Name
Me.daName.Selec tCommand.Parame ters("CustNo"). Value
= Session("CustNo ")
Me.daName.Fill( dsUserData)
Catch ex As Exception
Throw New Exception("Quer y Account Information: "
& ex.InnerExcepti on.Message & " " & ex.Message)
End Try
Try
'Get account service address
Me.daServiceAdd ress.SelectComm and.Parameters( "PremNo").V alue
= Session("PremNo ")
Me.daServiceAdd ress.Fill(dsUse rData)
Catch ex As Exception
Throw New Exception("Quer y Account Service
Address: " & ex.InnerExcepti on.Message & " " & ex.Message)
End Try
'set labels with data
lblAcctNo.Text = Session("CustNo ") & "-" &
Session("PremNo ")
Session("AcctNo ") = lblAcctNo.Text
Try
'get data from UCBCUST table and add data to
respective labels
FirstName = IIf(Not
IsDBNull(dsUser Data.Tables("UC BCUST").Rows(0) .Item("UCBCUST_ FIRST_NAME")),
dsUserData.Tabl es("UCBCUST").R ows(0).Item("UC BCUST_FIRST_NAM E"), "")
MiddleName = IIf(Not
IsDBNull(dsUser Data.Tables("UC BCUST").Rows(0) .Item("UCBCUST_ MIDDLE_NAME")),
dsUserData.Tabl es("UCBCUST").R ows(0).Item("UC BCUST_MIDDLE_NA ME"), "")
LastName = IIf(Not
IsDBNull(dsUser Data.Tables("UC BCUST").Rows(0) .Item("UCBCUST_ LAST_NAME")),
dsUserData.Tabl es("UCBCUST").R ows(0).Item("UC BCUST_LAST_NAME "), "")
PayByCheck = IIf(Not
IsDBNull(dsUser Data.Tables("UC BCUST").Rows(0) .Item("UCBCUST_ PAY_BY_CHECK_IN D")),
dsUserData.Tabl es("UCBCUST").R ows(0).Item("UC BCUST_PAY_BY_CH ECK_IND"),
"")
lblName.Text = IIf(Len(FirstNa me) > 0, FirstName &
" ", "") & _
IIf(Len(MiddleN ame) > 0, MiddleName
& " ", "") & _
IIf(Len(LastNam e) > 0, LastName,
"")
lblAllowedToPay ByCheck.Text = IIf(Len(PayByCh eck)
0, PayByCheck, "N") Catch ex As Exception
Throw New Exception("Retr ieve Account Information:
" & ex.InnerExcepti on.Message & " " & ex.Message)
End Try
'add data to session variables
Session("Name") = lblName.Text
Session("FirstN ame") = FirstName
Session("LastNa me") = LastName
Session("PayByC heck") = lblAllowedToPay ByCheck.Text
Try
'get address info from UCBPREM table
StreetName = IIf(Not
IsDBNull(dsUser Data.Tables("UC BPREM").Rows(0) .Item("UCBPREM_ STREET_NAME")),
dsUserData.Tabl es("UCBPREM").R ows(0).Item("UC BPREM_STREET_NA ME"), "")
StreetNumber = IIf(Not
IsDBNull(dsUser Data.Tables("UC BPREM").Rows(0) .Item("UCBPREM_ STREET_NUMBER") ),
dsUserData.Tabl es("UCBPREM").R ows(0).Item("UC BPREM_STREET_NU MBER"),
"")
PostDirection = IIf(Not
IsDBNull(dsUser Data.Tables("UC BPREM").Rows(0) .Item("UCBPREM_ PDIR_CODE_POST" )),
dsUserData.Tabl es("UCBPREM").R ows(0).Item("UC BPREM_PDIR_CODE _POST"),
"")
PreDirection = IIf(Not
IsDBNull(dsUser Data.Tables("UC BPREM").Rows(0) .Item("UCBPREM_ PDIR_CODE_PRE") ),
dsUserData.Tabl es("UCBPREM").R ows(0).Item("UC BPREM_PDIR_CODE _PRE"),
"")
ZipCode = IIf(Not
IsDBNull(dsUser Data.Tables("UC BPREM").Rows(0) .Item("UCBPREM_ ZIPC_CODE")),
dsUserData.Tabl es("UCBPREM").R ows(0).Item("UC BPREM_ZIPC_CODE "), "")
State = IIf(Not
IsDBNull(dsUser Data.Tables("UC BPREM").Rows(0) .Item("UCBPREM_ STAT_CODE_ADDR" )),
dsUserData.Tabl es("UCBPREM").R ows(0).Item("UC BPREM_STAT_CODE _ADDR"),
"")
Unit = IIf(Not
IsDBNull(dsUser Data.Tables("UC BPREM").Rows(0) .Item("UCBPREM_ UTYP_CODE")),
dsUserData.Tabl es("UCBPREM").R ows(0).Item("UC BPREM_UTYP_CODE "), "")
UnitNumber = IIf(Not
IsDBNull(dsUser Data.Tables("UC BPREM").Rows(0) .Item("UCBPREM_ UNIT")),
dsUserData.Tabl es("UCBPREM").R ows(0).Item("UC BPREM_UNIT"), "")
Suffix = IIf(Not
IsDBNull(dsUser Data.Tables("UC BPREM").Rows(0) .Item("UCBPREM_ SSFX_CODE")),
dsUserData.Tabl es("UCBPREM").R ows(0).Item("UC BPREM_SSFX_CODE "), "")
City = IIf(Not
IsDBNull(dsUser Data.Tables("UC BPREM").Rows(0) .Item("UCBPREM_ CITY")),
dsUserData.Tabl es("UCBPREM").R ows(0).Item("UC BPREM_CITY"), "")
lblAddress1.Tex t = IIf(Len(StreetN umber) > 0,
StreetNumber & " ", "") & _
IIf(Len(PreDire ction) > 0,
PreDirection & " ", "") & _
IIf(Len(StreetN ame) > 0,
StreetName & " ", "") & _
IIf(Len(Suffix) > 0, Suffix & "
", "") & _
IIf(Len(PostDir ection) > 0,
PostDirection & " ", "") & _
IIf(Len(Unit) > 0, Unit & " ",
"") & _
IIf(Len(UnitNum ber) > 0,
UnitNumber & " ", "")
lblAddress2.Tex t = IIf(Len(City) > 0, City & ", ",
"") & _
IIf(Len(State) > 0, State & "
", "") & _
IIf(Len(ZipCode ) > 0, ZipCode,
"")
Catch ex As Exception
Throw New Exception("Retr ieve Address Information:
" & ex.InnerExcepti on.Message & " " & ex.Message)
End Try
'add address lines to session variables
Session("Addres s1") = lblAddress1.Tex t
Session("Addres s2") = lblAddress2.Tex t
Session("City") = City
Session("State" ) = State
Session("ZipCod e") = ZipCode
Try
'get amount due ;)
lblAmountDue.Te xt = IIf(Not
IsDBNull(dsUser Data.Tables("SI I_BAL_VIEW").Ro ws(0).Item("BAL ANCE")),
dsUserData.Tabl es("SII_BAL_VIE W").Rows(0).Ite m("BALANCE"), "0")
Catch ex As Exception
Throw New Exception("Retr ieve Amount Due: " &
ex.InnerExcepti on.Message & " " & ex.Message)
End Try
'add amount due to session variables
Session("Amount Due") = lblAmountDue.Te xt
Try
'get amount due date ;)
If (dsUserData.Tab les("DUE_DATE_V IEW").Rows.Coun t 0) Then
lblDueDate.Text =
dsUserData.Tabl es("DUE_DATE_VI EW").Rows(0).It em("DUE_DATE")
Else
lblDueDate.Text = ""
End If
Catch ex As Exception
Throw New Exception("Retr ieve Due Date: " &
ex.InnerExcepti on.Message & " " & ex.Message)
End Try
'add due date to session variables
Session("DueDat e") = lblDueDate.Text
End If
Catch ex As Exception
Session("ErrorM essage") = "AccountAccess. Page_Load: " &
ex.InnerExcepti on.Message & " " & ex.Message
Response.Redire ct("../Error.aspx", False)
End Try
End Sub