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.NullReferenceException: 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:
[NullReferenceException: Object reference not set to an instance of an
object.]
login.AccountAccess.Page_Load(Object sender, EventArgs e) +7514
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
************************************************** *************************
***************CODE******************************* *************************
************************************************** *************************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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.Expires = 0
Response.ExpiresAbsolute = Now.AddDays(-1)
Response.CacheControl = "no-cache"
If (Not IsPostBack) Then
'******************************************
'****** Fill data in dataset **************
'******************************************
Try
'Get Balance Information
Me.daBalance.SelectCommand.Parameters("PremNo").Va lue
= Session("PremNo")
Me.daBalance.SelectCommand.Parameters("CustNo").Va lue
= Session("CustNo")
Me.daBalance.Fill(dsUserData)
Catch ex As Exception
Throw New Exception("Query Balance Information: "
& ex.InnerException.Message & " " & ex.Message)
End Try
Try
'Get the due date
Me.daDueDate.SelectCommand.Parameters("PremNo").Va lue
= Session("PremNo")
Me.daDueDate.SelectCommand.Parameters("CustNo").Va lue
= Session("CustNo")
Me.daDueDate.Fill(dsUserData)
Catch ex As Exception
Throw New Exception("Query Due Date: " &
ex.InnerException.Message & " " & ex.Message)
End Try
Try
'Get Account Name
Me.daName.SelectCommand.Parameters("CustNo").Value
= Session("CustNo")
Me.daName.Fill(dsUserData)
Catch ex As Exception
Throw New Exception("Query Account Information: "
& ex.InnerException.Message & " " & ex.Message)
End Try
Try
'Get account service address
Me.daServiceAddress.SelectCommand.Parameters("Prem No").Value
= Session("PremNo")
Me.daServiceAddress.Fill(dsUserData)
Catch ex As Exception
Throw New Exception("Query Account Service
Address: " & ex.InnerException.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(dsUserData.Tables("UCBCUST").Rows(0).Item ("UCBCUST_FIRST_NAME")),
dsUserData.Tables("UCBCUST").Rows(0).Item("UCBCUST _FIRST_NAME"), "")
MiddleName = IIf(Not
IsDBNull(dsUserData.Tables("UCBCUST").Rows(0).Item ("UCBCUST_MIDDLE_NAME")),
dsUserData.Tables("UCBCUST").Rows(0).Item("UCBCUST _MIDDLE_NAME"), "")
LastName = IIf(Not
IsDBNull(dsUserData.Tables("UCBCUST").Rows(0).Item ("UCBCUST_LAST_NAME")),
dsUserData.Tables("UCBCUST").Rows(0).Item("UCBCUST _LAST_NAME"), "")
PayByCheck = IIf(Not
IsDBNull(dsUserData.Tables("UCBCUST").Rows(0).Item ("UCBCUST_PAY_BY_CHECK_IND")),
dsUserData.Tables("UCBCUST").Rows(0).Item("UCBCUST _PAY_BY_CHECK_IND"),
"")
lblName.Text = IIf(Len(FirstName) > 0, FirstName &
" ", "") & _
IIf(Len(MiddleName) > 0, MiddleName
& " ", "") & _
IIf(Len(LastName) > 0, LastName,
"")
lblAllowedToPayByCheck.Text = IIf(Len(PayByCheck)
0, PayByCheck, "N") Catch ex As Exception
Throw New Exception("Retrieve Account Information:
" & ex.InnerException.Message & " " & ex.Message)
End Try
'add data to session variables
Session("Name") = lblName.Text
Session("FirstName") = FirstName
Session("LastName") = LastName
Session("PayByCheck") = lblAllowedToPayByCheck.Text
Try
'get address info from UCBPREM table
StreetName = IIf(Not
IsDBNull(dsUserData.Tables("UCBPREM").Rows(0).Item ("UCBPREM_STREET_NAME")),
dsUserData.Tables("UCBPREM").Rows(0).Item("UCBPREM _STREET_NAME"), "")
StreetNumber = IIf(Not
IsDBNull(dsUserData.Tables("UCBPREM").Rows(0).Item ("UCBPREM_STREET_NUMBER")),
dsUserData.Tables("UCBPREM").Rows(0).Item("UCBPREM _STREET_NUMBER"),
"")
PostDirection = IIf(Not
IsDBNull(dsUserData.Tables("UCBPREM").Rows(0).Item ("UCBPREM_PDIR_CODE_POST")),
dsUserData.Tables("UCBPREM").Rows(0).Item("UCBPREM _PDIR_CODE_POST"),
"")
PreDirection = IIf(Not
IsDBNull(dsUserData.Tables("UCBPREM").Rows(0).Item ("UCBPREM_PDIR_CODE_PRE")),
dsUserData.Tables("UCBPREM").Rows(0).Item("UCBPREM _PDIR_CODE_PRE"),
"")
ZipCode = IIf(Not
IsDBNull(dsUserData.Tables("UCBPREM").Rows(0).Item ("UCBPREM_ZIPC_CODE")),
dsUserData.Tables("UCBPREM").Rows(0).Item("UCBPREM _ZIPC_CODE"), "")
State = IIf(Not
IsDBNull(dsUserData.Tables("UCBPREM").Rows(0).Item ("UCBPREM_STAT_CODE_ADDR")),
dsUserData.Tables("UCBPREM").Rows(0).Item("UCBPREM _STAT_CODE_ADDR"),
"")
Unit = IIf(Not
IsDBNull(dsUserData.Tables("UCBPREM").Rows(0).Item ("UCBPREM_UTYP_CODE")),
dsUserData.Tables("UCBPREM").Rows(0).Item("UCBPREM _UTYP_CODE"), "")
UnitNumber = IIf(Not
IsDBNull(dsUserData.Tables("UCBPREM").Rows(0).Item ("UCBPREM_UNIT")),
dsUserData.Tables("UCBPREM").Rows(0).Item("UCBPREM _UNIT"), "")
Suffix = IIf(Not
IsDBNull(dsUserData.Tables("UCBPREM").Rows(0).Item ("UCBPREM_SSFX_CODE")),
dsUserData.Tables("UCBPREM").Rows(0).Item("UCBPREM _SSFX_CODE"), "")
City = IIf(Not
IsDBNull(dsUserData.Tables("UCBPREM").Rows(0).Item ("UCBPREM_CITY")),
dsUserData.Tables("UCBPREM").Rows(0).Item("UCBPREM _CITY"), "")
lblAddress1.Text = IIf(Len(StreetNumber) > 0,
StreetNumber & " ", "") & _
IIf(Len(PreDirection) > 0,
PreDirection & " ", "") & _
IIf(Len(StreetName) > 0,
StreetName & " ", "") & _
IIf(Len(Suffix) > 0, Suffix & "
", "") & _
IIf(Len(PostDirection) > 0,
PostDirection & " ", "") & _
IIf(Len(Unit) > 0, Unit & " ",
"") & _
IIf(Len(UnitNumber) > 0,
UnitNumber & " ", "")
lblAddress2.Text = IIf(Len(City) > 0, City & ", ",
"") & _
IIf(Len(State) > 0, State & "
", "") & _
IIf(Len(ZipCode) > 0, ZipCode,
"")
Catch ex As Exception
Throw New Exception("Retrieve Address Information:
" & ex.InnerException.Message & " " & ex.Message)
End Try
'add address lines to session variables
Session("Address1") = lblAddress1.Text
Session("Address2") = lblAddress2.Text
Session("City") = City
Session("State") = State
Session("ZipCode") = ZipCode
Try
'get amount due ;)
lblAmountDue.Text = IIf(Not
IsDBNull(dsUserData.Tables("SII_BAL_VIEW").Rows(0) .Item("BALANCE")),
dsUserData.Tables("SII_BAL_VIEW").Rows(0).Item("BA LANCE"), "0")
Catch ex As Exception
Throw New Exception("Retrieve Amount Due: " &
ex.InnerException.Message & " " & ex.Message)
End Try
'add amount due to session variables
Session("AmountDue") = lblAmountDue.Text
Try
'get amount due date ;)
If (dsUserData.Tables("DUE_DATE_VIEW").Rows.Count 0) Then
lblDueDate.Text =
dsUserData.Tables("DUE_DATE_VIEW").Rows(0).Item("D UE_DATE")
Else
lblDueDate.Text = ""
End If
Catch ex As Exception
Throw New Exception("Retrieve Due Date: " &
ex.InnerException.Message & " " & ex.Message)
End Try
'add due date to session variables
Session("DueDate") = lblDueDate.Text
End If
Catch ex As Exception
Session("ErrorMessage") = "AccountAccess.Page_Load: " &
ex.InnerException.Message & " " & ex.Message
Response.Redirect("../Error.aspx", False)
End Try
End Sub