I'm relatively familiar with asp.net and vb.net and have been working in
the environment for several years. I've dealt with null reference errors
before and generally know how to code around them
But now I have some new code I deployed and I'm getting a null reference
error when looping through a datatable (for each r in dt.rows...).
I'm expecting to find an integer in this field, or possibly nothing, or
possibly a dash (-).
So I added some extra stuff to figure out what's in there (I don;t have
access to the same dataset where this is running, or I'd just use the
debugger). I made this block of code to help me figure it out:
If IsNumeric(Trim(r("qty_rem"))) Then 'Trim(r("qty_rem")) <"-" And
Trim(r("qty_rem")) <"" Then
Dim iRem As Int16
Try
iRem = Convert.ToInt16(Trim(r("qty_rem")))
Catch ex As Exception
If Not IsNothing(r("qty_rem")) Then
Current.Session("lastError") = "r(qty_rem) = '" & r("qty_rem") & "'"
& vbCrLf & ex.Message & vbCrLf & ex.InnerException.Message
Current.Response.Redirect("error.aspx")
Else
Current.Session("lastError") = "r(qty_rem) is nothing" & vbCrLf &
ex.Message & vbCrLf & ex.InnerException.Message
Current.Response.Redirect("error.aspx")
End If
End Try
And now instead of redirecting to my error page and showing me what is
in there, it crashes on the line where it tries to assign values to the
"lastError" session variable. But it passes If not isNothing() and
IsNumeric(). I don't get it. Can anyone see the problem in finding out
what is in this dataset? Thanks!
Matt 5 1470
try testing if r("qty_rem") is nothing first
"MattB" <so********@yahoo.comwrote in message
news:5n************@mid.individual.net...
I'm relatively familiar with asp.net and vb.net and have been working in
the environment for several years. I've dealt with null reference errors
before and generally know how to code around them
But now I have some new code I deployed and I'm getting a null reference
error when looping through a datatable (for each r in dt.rows...).
I'm expecting to find an integer in this field, or possibly nothing, or
possibly a dash (-).
So I added some extra stuff to figure out what's in there (I don;t have
access to the same dataset where this is running, or I'd just use the
debugger). I made this block of code to help me figure it out:
If IsNumeric(Trim(r("qty_rem"))) Then 'Trim(r("qty_rem")) <"-" And
Trim(r("qty_rem")) <"" Then
Dim iRem As Int16
Try
iRem = Convert.ToInt16(Trim(r("qty_rem")))
Catch ex As Exception
If Not IsNothing(r("qty_rem")) Then
Current.Session("lastError") = "r(qty_rem) = '" & r("qty_rem") & "'" &
vbCrLf & ex.Message & vbCrLf & ex.InnerException.Message
Current.Response.Redirect("error.aspx")
Else
Current.Session("lastError") = "r(qty_rem) is nothing" & vbCrLf &
ex.Message & vbCrLf & ex.InnerException.Message
Current.Response.Redirect("error.aspx")
End If
End Try
And now instead of redirecting to my error page and showing me what is in
there, it crashes on the line where it tries to assign values to the
"lastError" session variable. But it passes If not isNothing() and
IsNumeric(). I don't get it. Can anyone see the problem in finding out
what is in this dataset? Thanks!
Matt
Thanks for responding!
I'm doing that in this snippet below in the catch block and it passes
(it's not nothing). Then it errors where I'm assigning relevant info to
the session variable.
Any other ideas? I really do appreciate the response!
Matt
IfThenElse wrote:
try testing if r("qty_rem") is nothing first
"MattB" <so********@yahoo.comwrote in message
news:5n************@mid.individual.net...
>I'm relatively familiar with asp.net and vb.net and have been working in the environment for several years. I've dealt with null reference errors before and generally know how to code around them But now I have some new code I deployed and I'm getting a null reference error when looping through a datatable (for each r in dt.rows...). I'm expecting to find an integer in this field, or possibly nothing, or possibly a dash (-). So I added some extra stuff to figure out what's in there (I don;t have access to the same dataset where this is running, or I'd just use the debugger). I made this block of code to help me figure it out:
If IsNumeric(Trim(r("qty_rem"))) Then 'Trim(r("qty_rem")) <"-" And Trim(r("qty_rem")) <"" Then Dim iRem As Int16 Try iRem = Convert.ToInt16(Trim(r("qty_rem"))) Catch ex As Exception If Not IsNothing(r("qty_rem")) Then Current.Session("lastError") = "r(qty_rem) = '" & r("qty_rem") & "'" & vbCrLf & ex.Message & vbCrLf & ex.InnerException.Message Current.Response.Redirect("error.aspx") Else Current.Session("lastError") = "r(qty_rem) is nothing" & vbCrLf & ex.Message & vbCrLf & ex.InnerException.Message Current.Response.Redirect("error.aspx") End If End Try
And now instead of redirecting to my error page and showing me what is in there, it crashes on the line where it tries to assign values to the "lastError" session variable. But it passes If not isNothing() and IsNumeric(). I don't get it. Can anyone see the problem in finding out what is in this dataset? Thanks!
Matt
May be your ex.InnerException.Message is nothing. check it out.
I use,
If Not ( r("qty_rem") is nothing ) then
may be the same as NOT IsNothing(etc..)
"MattB" <so********@yahoo.comwrote in message
news:5n************@mid.individual.net...
Thanks for responding!
I'm doing that in this snippet below in the catch block and it passes
(it's not nothing). Then it errors where I'm assigning relevant info to
the session variable.
Any other ideas? I really do appreciate the response!
Matt
IfThenElse wrote:
>try testing if r("qty_rem") is nothing first
"MattB" <so********@yahoo.comwrote in message news:5n************@mid.individual.net...
>>I'm relatively familiar with asp.net and vb.net and have been working in the environment for several years. I've dealt with null reference errors before and generally know how to code around them But now I have some new code I deployed and I'm getting a null reference error when looping through a datatable (for each r in dt.rows...). I'm expecting to find an integer in this field, or possibly nothing, or possibly a dash (-). So I added some extra stuff to figure out what's in there (I don;t have access to the same dataset where this is running, or I'd just use the debugger). I made this block of code to help me figure it out:
If IsNumeric(Trim(r("qty_rem"))) Then 'Trim(r("qty_rem")) <"-" And Trim(r("qty_rem")) <"" Then Dim iRem As Int16 Try iRem = Convert.ToInt16(Trim(r("qty_rem"))) Catch ex As Exception If Not IsNothing(r("qty_rem")) Then Current.Session("lastError") = "r(qty_rem) = '" & r("qty_rem") & "'" & vbCrLf & ex.Message & vbCrLf & ex.InnerException.Message Current.Response.Redirect("error.aspx") Else Current.Session("lastError") = "r(qty_rem) is nothing" & vbCrLf & ex.Message & vbCrLf & ex.InnerException.Message Current.Response.Redirect("error.aspx") End If End Try
And now instead of redirecting to my error page and showing me what is in there, it crashes on the line where it tries to assign values to the "lastError" session variable. But it passes If not isNothing() and IsNumeric(). I don't get it. Can anyone see the problem in finding out what is in this dataset? Thanks!
Matt
if it null in the database, r("qty_rem") returns DBNull, not null (nothing).
-- bruce (sqlwork.com)
MattB wrote:
I'm relatively familiar with asp.net and vb.net and have been working in
the environment for several years. I've dealt with null reference errors
before and generally know how to code around them
But now I have some new code I deployed and I'm getting a null reference
error when looping through a datatable (for each r in dt.rows...).
I'm expecting to find an integer in this field, or possibly nothing, or
possibly a dash (-).
So I added some extra stuff to figure out what's in there (I don;t have
access to the same dataset where this is running, or I'd just use the
debugger). I made this block of code to help me figure it out:
If IsNumeric(Trim(r("qty_rem"))) Then 'Trim(r("qty_rem")) <"-" And
Trim(r("qty_rem")) <"" Then
Dim iRem As Int16
Try
iRem = Convert.ToInt16(Trim(r("qty_rem")))
Catch ex As Exception
If Not IsNothing(r("qty_rem")) Then
Current.Session("lastError") = "r(qty_rem) = '" &
r("qty_rem") & "'" & vbCrLf & ex.Message & vbCrLf &
ex.InnerException.Message
Current.Response.Redirect("error.aspx")
Else
Current.Session("lastError") = "r(qty_rem) is nothing" &
vbCrLf & ex.Message & vbCrLf & ex.InnerException.Message
Current.Response.Redirect("error.aspx")
End If
End Try
And now instead of redirecting to my error page and showing me what is
in there, it crashes on the line where it tries to assign values to the
"lastError" session variable. But it passes If not isNothing() and
IsNumeric(). I don't get it. Can anyone see the problem in finding out
what is in this dataset? Thanks!
Matt
good point
"bruce barker" <no****@nospam.comwrote in message
news:eK**************@TK2MSFTNGP04.phx.gbl...
if it null in the database, r("qty_rem") returns DBNull, not null
(nothing).
-- bruce (sqlwork.com)
MattB wrote:
>I'm relatively familiar with asp.net and vb.net and have been working in the environment for several years. I've dealt with null reference errors before and generally know how to code around them But now I have some new code I deployed and I'm getting a null reference error when looping through a datatable (for each r in dt.rows...). I'm expecting to find an integer in this field, or possibly nothing, or possibly a dash (-). So I added some extra stuff to figure out what's in there (I don;t have access to the same dataset where this is running, or I'd just use the debugger). I made this block of code to help me figure it out:
If IsNumeric(Trim(r("qty_rem"))) Then 'Trim(r("qty_rem")) <"-" And Trim(r("qty_rem")) <"" Then Dim iRem As Int16 Try iRem = Convert.ToInt16(Trim(r("qty_rem"))) Catch ex As Exception If Not IsNothing(r("qty_rem")) Then Current.Session("lastError") = "r(qty_rem) = '" & r("qty_rem") & "'" & vbCrLf & ex.Message & vbCrLf & ex.InnerException.Message Current.Response.Redirect("error.aspx") Else Current.Session("lastError") = "r(qty_rem) is nothing" & vbCrLf & ex.Message & vbCrLf & ex.InnerException.Message Current.Response.Redirect("error.aspx") End If End Try
And now instead of redirecting to my error page and showing me what is in there, it crashes on the line where it tries to assign values to the "lastError" session variable. But it passes If not isNothing() and IsNumeric(). I don't get it. Can anyone see the problem in finding out what is in this dataset? Thanks!
Matt
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Robert Schott |
last post by:
Hi .. this is for sure the 1k question on fopen but maybe can someone
tell me this weird staff
if i'm writing:
$H = fopen($value,"r");
while(!feof($H))
{
$string = fgets($H,1024);
....
.......
|
by: HelLind |
last post by:
Hello people,
I am having a weird error and don't know what term to search in
google. Sorry to bother.
There is data in my field "M_BIO"
When I run this code...
|
by: Etienne Charland |
last post by:
Hi, I have a solution containing 6 C# projects; 1 WinForms project and 5
class libraries. I didn't have any problems until recently. I added a new
project containing reports. I am using...
|
by: Deutsche Dogge |
last post by:
Hi. I'M having a weird problem with addign menuitems to a menu dynamically
on the popup event of the menuitem containing the container of the
menuitems i wanna add (tools -> external -> {list of...
|
by: MX1 |
last post by:
OK, here's one that's driving me nuts. Three tables. They are...
Master Table
JobRef Reference Table
ToolRef Reference Table
I've got a form for...
|
by: Paul S. Natanson |
last post by:
What is a Null Reference error and how do I fix it?
My newly installed VB.Net2003 gives me a "Microsoft
Development Environment" error message box EVERY time I
try to run/start ANY project -...
|
by: ian |
last post by:
Hi, I've got the weirdest garbage collection problem - I'd appreciate any
advice you've got.
1. A class 'X' in a system I'm working on contains a reference to an
XmlDocument, populated via...
|
by: Flack |
last post by:
I have a DataGrid and a DataTable. When my form loads I create the DataTable
with the appropriate columns and use it for the DataGrids.DataSource.
Later on in my app, I alter the DataTable:
...
|
by: David W |
last post by:
I'm almost tearing my hair out. A colleague claimed that a null reference can exist, like
this:
void f( int& p )
{
printf( "%d\n", p );
}
int main (int argc, char *argv)
{
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |