Last post Mar 13, 2009 12:52 PM by DkUltra
Mar 11, 2009 07:53 PM|rmethod|LINK
I really hope someone can answer this because i'm at my wits end. I have the following code in a DLL class and it works for a time, but then I receive the following error:
System.NullReferenceException: Object reference not set to an instance of an object. at _Default.GetEvent()
Here is the code for the GetEvent()
And here is the code for the doRandomEvent()
And finally, here is the final piece of code.
myDataReader = myCommand.ExecuteReader
myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
I've also included the SP code. It returns a random record everytime the page is refreshed.
ORDER BY NEWID
I've also included the live website that is having the issue. Here is the url:
I've got it setup to autorefresh and it works fine for approx 30 minutes, then it errors out.
The code above is a direct copy of this book code:
Thanks in advance for any help.
Mar 12, 2009 12:45 PM|asifchouhan|LINK
one problem i have notified that whenever your read an datareader
drEvent.Read() you should always close it after using it
If u find my post helpful. Mark it as "ANSWER"
Mar 13, 2009 12:52 PM|DkUltra|LINK
Books always seem to have bad error checking.
A person could
if not myDataReader is nothing
LogError("Your message none found ")
If not drEvent("EVENTDESC") is nothing andalso drEvent("EVENTDESC").ToString() = "" then
.....(" .... ")
Hope this Helps