473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

"Object reference not set to an instance of an object"

I am getting the above error on If arrFields is nothing or
arrFields.Count=0, I don't understand why I am getting the error:

dim arrFields as new ArrayList
arrFields = CType(ViewState("arrFields"), ArrayList)
--this is where I get the error:
If arrFields is nothing or arrFields.Count=0 then
Call GetFields
ViewState("arrFields") = arrFields
end if
End If

Does anyone know why I would be getting this error, when in fact the object
is set?
Nov 19 '05 #1
4 1231
Jon
Not sure, it seems like the object should be there.

Try using If arrFields is nothing OrElse arrFields.Count=0 then, in stead of
just Or and see if it makes a difference...
"Rock" <ro********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I am getting the above error on If arrFields is nothing or
arrFields.Count=0, I don't understand why I am getting the error:

dim arrFields as new ArrayList
arrFields = CType(ViewState("arrFields"), ArrayList)
--this is where I get the error:
If arrFields is nothing or arrFields.Count=0 then
Call GetFields
ViewState("arrFields") = arrFields
end if
End If

Does anyone know why I would be getting this error, when in fact the
object
is set?

Nov 19 '05 #2

"Rock" <ro********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I am getting the above error on If arrFields is nothing or
arrFields.Count=0, I don't understand why I am getting the error:

dim arrFields as new ArrayList
arrFields = CType(ViewState("arrFields"), ArrayList)
--this is where I get the error:
If arrFields is nothing or arrFields.Count=0 then
Call GetFields
ViewState("arrFields") = arrFields
end if
End If

Does anyone know why I would be getting this error, when in fact the object is set?

When I store things in viewstate, I always check for the ViewState being
nothing before I access it. Try adding
If not ViewState("arrFields") is nothing then ....
Mike
Nov 19 '05 #3
vb does not shortcut ifs, so if arrField is nothing, you will get an error
on the "or arrFields.Count=0" clause, which will happen if the object is
not in the viewstate.

-- bruce (sqlwork.com)
"Rock" <ro********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
| I am getting the above error on If arrFields is nothing or
| arrFields.Count=0, I don't understand why I am getting the error:
|
| dim arrFields as new ArrayList
| arrFields = CType(ViewState("arrFields"), ArrayList)
| --this is where I get the error:
| If arrFields is nothing or arrFields.Count=0 then
| Call GetFields
| ViewState("arrFields") = arrFields
| end if
| End If
|
| Does anyone know why I would be getting this error, when in fact the
object
| is set?
|
|
Nov 19 '05 #4
Thanks. The OrElse worked, and so does checking the viewstate first. I
will keep this in mind, I now understand why it happened. Thanks all!
"bruce barker" <no***********@safeco.com> wrote in message
news:e6**************@TK2MSFTNGP14.phx.gbl...
vb does not shortcut ifs, so if arrField is nothing, you will get an error
on the "or arrFields.Count=0" clause, which will happen if the object is
not in the viewstate.

-- bruce (sqlwork.com)
"Rock" <ro********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
| I am getting the above error on If arrFields is nothing or
| arrFields.Count=0, I don't understand why I am getting the error:
|
| dim arrFields as new ArrayList
| arrFields = CType(ViewState("arrFields"), ArrayList)
| --this is where I get the error:
| If arrFields is nothing or arrFields.Count=0 then
| Call GetFields
| ViewState("arrFields") = arrFields
| end if
| End If
|
| Does anyone know why I would be getting this error, when in fact the
object
| is set?
|
|

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bob Cannistraci | last post by:
A three-tier user authentication system was running without a problem for almost a year and now is suddenly dysfunctional. We don't know of any changes to any of the servers. It's quite maddening....
0
by: Bob Cannistraci | last post by:
A three-tier user authentication system was running without a problem for almost a year and now is suddenly dysfunctional. We don't know of any changes to any of the servers. It's quite maddening....
1
by: Bob Cannistraci | last post by:
A three-tier user authentication system was running without a problem for almost a year and now is suddenly dysfunctional. We don't know of any changes to any of the servers. It's quite maddening....
1
by: Chris Magoun | last post by:
I suddenly received an unexpected error in my project. I have been working on this project for some time without this issue. Nothing has changed in the form that caused the exception. A little...
18
by: Microsoft | last post by:
When I try this in my code I alwas get an errormessage: "Object reference not set to an instance of an object" Dim g As System.Drawing.Graphics g.DrawString("Test", New Font("Arial", 12,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.