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_re m")) <"-" And
Trim(r("qty_rem ")) <"" Then
Dim iRem As Int16
Try
iRem = Convert.ToInt16 (Trim(r("qty_re m")))
Catch ex As Exception
If Not IsNothing(r("qt y_rem")) Then
Current.Session ("lastError" ) = "r(qty_rem) = '" & r("qty_rem") & "'"
& vbCrLf & ex.Message & vbCrLf & ex.InnerExcepti on.Message
Current.Respons e.Redirect("err or.aspx")
Else
Current.Session ("lastError" ) = "r(qty_rem) is nothing" & vbCrLf &
ex.Message & vbCrLf & ex.InnerExcepti on.Message
Current.Respons e.Redirect("err or.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 1508
try testing if r("qty_rem") is nothing first
"MattB" <so********@yah oo.comwrote in message
news:5n******** ****@mid.indivi dual.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_re m")) <"-" And
Trim(r("qty_rem ")) <"" Then
Dim iRem As Int16
Try
iRem = Convert.ToInt16 (Trim(r("qty_re m")))
Catch ex As Exception
If Not IsNothing(r("qt y_rem")) Then
Current.Session ("lastError" ) = "r(qty_rem) = '" & r("qty_rem") & "'" &
vbCrLf & ex.Message & vbCrLf & ex.InnerExcepti on.Message
Current.Respons e.Redirect("err or.aspx")
Else
Current.Session ("lastError" ) = "r(qty_rem) is nothing" & vbCrLf &
ex.Message & vbCrLf & ex.InnerExcepti on.Message
Current.Respons e.Redirect("err or.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********@yah oo.comwrote in message
news:5n******** ****@mid.indivi dual.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_re m")) <"-" And Trim(r("qty_re m")) <"" Then Dim iRem As Int16 Try iRem = Convert.ToInt16 (Trim(r("qty_re m"))) Catch ex As Exception If Not IsNothing(r("qt y_rem")) Then Current.Sessio n("lastError" ) = "r(qty_rem) = '" & r("qty_rem") & "'" & vbCrLf & ex.Message & vbCrLf & ex.InnerExcepti on.Message Current.Respon se.Redirect("er ror.aspx") Else Current.Sessio n("lastError" ) = "r(qty_rem) is nothing" & vbCrLf & ex.Message & vbCrLf & ex.InnerExcepti on.Message Current.Respon se.Redirect("er ror.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.InnerExcepti on.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********@yah oo.comwrote in message
news:5n******** ****@mid.indivi dual.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********@yah oo.comwrote in message news:5n******* *****@mid.indiv idual.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_re m")) <"-" And Trim(r("qty_r em")) <"" Then Dim iRem As Int16 Try iRem = Convert.ToInt16 (Trim(r("qty_re m"))) Catch ex As Exception If Not IsNothing(r("qt y_rem")) Then Current.Sessi on("lastError" ) = "r(qty_rem) = '" & r("qty_rem") & "'" & vbCrLf & ex.Message & vbCrLf & ex.InnerExcepti on.Message Current.Respo nse.Redirect("e rror.aspx") Else Current.Sessi on("lastError" ) = "r(qty_rem) is nothing" & vbCrLf & ex.Message & vbCrLf & ex.InnerExcepti on.Message Current.Respo nse.Redirect("e rror.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_re m")) <"-" And
Trim(r("qty_rem ")) <"" Then
Dim iRem As Int16
Try
iRem = Convert.ToInt16 (Trim(r("qty_re m")))
Catch ex As Exception
If Not IsNothing(r("qt y_rem")) Then
Current.Session ("lastError" ) = "r(qty_rem) = '" &
r("qty_rem") & "'" & vbCrLf & ex.Message & vbCrLf &
ex.InnerExcepti on.Message
Current.Respons e.Redirect("err or.aspx")
Else
Current.Session ("lastError" ) = "r(qty_rem) is nothing" &
vbCrLf & ex.Message & vbCrLf & ex.InnerExcepti on.Message
Current.Respons e.Redirect("err or.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******** ******@TK2MSFTN GP04.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_re m")) <"-" And Trim(r("qty_re m")) <"" Then Dim iRem As Int16 Try iRem = Convert.ToInt16 (Trim(r("qty_re m"))) Catch ex As Exception If Not IsNothing(r("qt y_rem")) Then Current.Session ("lastError" ) = "r(qty_rem) = '" & r("qty_rem") & "'" & vbCrLf & ex.Message & vbCrLf & ex.InnerExcept ion.Message Current.Respons e.Redirect("err or.aspx") Else Current.Session ("lastError" ) = "r(qty_rem) is nothing" & vbCrLf & ex.Message & vbCrLf & ex.InnerExcepti on.Message Current.Respons e.Redirect("err or.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);
....
.... blabla
|
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 <%=rslist.Fields.Item("M_bio").Value%>, it
displays the data, no problem.
|
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 ActiveReports.Net. Now, whenever I
make a change to a report in the class library and recompile, I get this
error: "Could not copy temporary files to the output directory.". I have to
close VS.Net and reopen it in order to recompile, this is very cumbersome....
|
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 items dynamically
added})
All the code works #1 when only the MdiParent form is used, as soon as i
open an MdiChild in it, right after the popup event returns, i get this
error:
...
|
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 Master that has a combo box to let you select from both
of these reference tables. When I make a new record, the system lets me
leave JobRef combo box null and save the record. However, I can't save the
record unless the ToolRef combo box has a...
| |
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 - even very simple ones.
The error says:
"An unhandled exception of
type 'System.NullReferenceException' occurred in
|
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 LoadXML.
2. Objects of type X are reused alot so different XML is loaded numerous
times.
3. If I keep this reference, the system looses more and more memory until it
|
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:
dt.BeginLoadData();
for(int i = 0; i < _movesArrayList.Count; i++)
{
string columnValues = ((string)_movesArrayList).Split(COL_SEPARATOR);
DataRow _moveRow = dt.NewRow();
|
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: 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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |