469,589 Members | 2,157 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,589 developers. It's quick & easy.

intermittant error on web server

I hope that someone can help me out there with this problem.

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
Nov 18 '05 #1
2 1422
Consider refactoring your code to improve readability and substantially
lower your maintenance cost.

With that out of the way, I'll have to defer to the holywoord popularized
ockham's razor. In this case, the simplest explanation I see is the
exception is occuring in your final catch block:

Session("ErrorMessage") = "AccountAccess.Page_Load: " &
ex.InnerException.Message & " " & ex.Message
Response.Redirect("../Error.aspx", False)

it's possible that ex.InnerException is null/nothing is my only
guess.....if your code caused a SystemOutOfMemory exception for example, I
believe you might see that...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"James Wallace" <jw******@btutilities.com> wrote in message
news:a5**************************@posting.google.c om...
I hope that someone can help me out there with this problem.

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

Nov 18 '05 #2
jw******@btutilities.com (James Wallace) wrote in message news:<a5**************************@posting.google. com>...
I hope that someone can help me out there with this problem.

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

Did you find a solution on this? I have a new, similar issue with a
server running XP. I'm wondering if it has to do with Installing XP
Service Pack 2.

David
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Michael Mossey | last post: by
reply views Thread by Nick Jushchyshyn | last post: by
1 post views Thread by Sean C. | last post: by
reply views Thread by Mark Phanides | last post: by
2 posts views Thread by Chuck Ritzke | last post: by
reply views Thread by Steve Schaenzer | last post: by
reply views Thread by bob | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.