473,840 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

null reference

I use session:

If IsDBNull(Sessio n("Source")) Then ' this is the line cause an error
bindRptSell()
End If

But I get an error message:

Object variable or With block variable not set.
System.NullRefe renceException: Object variable or With block variable not
set.

Why? I check for null.

Simon
Nov 19 '05 #1
5 1777
simon wrote:
I use session:

If IsDBNull(Sessio n("Source")) Then ' this is the line cause an error
bindRptSell()
End If

But I get an error message:

Object variable or With block variable not set.
System.NullRefe renceException: Object variable or With block variable not
set.

Why? I check for null.

Simon


No, you check for "DbNull", which is DbNull.Value. This is *not* the
same as "null" (or "Nothing" in VB).

try:
If Session("Source ") Is Nothing Then ...
--
Hans Kesting
Nov 19 '05 #2
Thank you

regards,
Simon

"Hans Kesting" <ne***********@ spamgourmet.com > wrote in message
news:O%******** ********@tk2msf tngp13.phx.gbl. ..
simon wrote:
I use session:

If IsDBNull(Sessio n("Source")) Then ' this is the line cause an error
bindRptSell()
End If

But I get an error message:

Object variable or With block variable not set.
System.NullRefe renceException: Object variable or With block variable not
set.

Why? I check for null.

Simon


No, you check for "DbNull", which is DbNull.Value. This is *not* the same
as "null" (or "Nothing" in VB).

try:
If Session("Source ") Is Nothing Then ...
--
Hans Kesting

Nov 19 '05 #3
Hi,

Why do you check your session for DBNull???
DBNull is just for a database.

if(Session[''aaa'] == null)

just like that

bye

"simon" <si*********@st ud-moderna.si> wrote in message
news:e4******** *****@TK2MSFTNG P12.phx.gbl...
I use session:

If IsDBNull(Sessio n("Source")) Then ' this is the line cause an error
bindRptSell()
End If

But I get an error message:

Object variable or With block variable not set.
System.NullRefe renceException: Object variable or With block variable not
set.

Why? I check for null.

Simon

Nov 19 '05 #4
Hi Michael,

If I use Session[''aaa'] =null I get the following error message:

'null' is not declared. 'Null' costant is no longer suported; use
'System.DBNull' instead.

So, that's way I'm using DBNull.

By the way, I'm writing in VB language. I heard that in C# that is possible,
to compare with null value.

Any comment?

Regards,
Simon

"Michael Tkachev" <m_*******@hotm ail.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi,

Why do you check your session for DBNull???
DBNull is just for a database.

if(Session[''aaa'] == null)

just like that

bye

"simon" <si*********@st ud-moderna.si> wrote in message
news:e4******** *****@TK2MSFTNG P12.phx.gbl...
I use session:

If IsDBNull(Sessio n("Source")) Then ' this is the line cause an error
bindRptSell()
End If

But I get an error message:

Object variable or With block variable not set.
System.NullRefe renceException: Object variable or With block variable not
set.

Why? I check for null.

Simon


Nov 19 '05 #5
C# uses "null".

VB uses "Nothing".

Try

If IsNothing(Sessi on("Source")) Then
....rest of code
End If

You could also set a variable equal to Session("Source ")
and then the code would look a bit cleaner :

Dim varSource as String=Session( "Source")
If IsNothing(varSo urce) Then
....rest of code
End If

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
=============== =======

"simon" <si*********@st ud-moderna.si> wrote in message
news:Ok******** ******@TK2MSFTN GP12.phx.gbl...
Hi Michael,

If I use Session[''aaa'] =null I get the following error message:

'null' is not declared. 'Null' costant is no longer suported; use
'System.DBNull' instead.

So, that's way I'm using DBNull.

By the way, I'm writing in VB language. I heard that in C# that is
possible, to compare with null value.

Any comment?

Regards,
Simon

"Michael Tkachev" <m_*******@hotm ail.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi,

Why do you check your session for DBNull???
DBNull is just for a database.

if(Session[''aaa'] == null)

just like that

bye

"simon" <si*********@st ud-moderna.si> wrote in message
news:e4******** *****@TK2MSFTNG P12.phx.gbl...
I use session:

If IsDBNull(Sessio n("Source")) Then ' this is the line cause an error
bindRptSell()
End If

But I get an error message:

Object variable or With block variable not set.
System.NullRefe renceException: Object variable or With block variable
not
set.

Why? I check for null.

Simon



Nov 19 '05 #6

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

Similar topics

7
20387
by: Pablo J Royo | last post by:
Hello: i have a function that reads a file as an argument and returns a reference to an object that contains some information obtained from the file: FData &ReadFile(string FilePath); But , for example, when the file doesnt exists, i should not return any reference to a bad constructed object, so i need something as a NULL reference object. I suppose i could return a pointer instead, but i have some code written with references which...
3
3393
by: Marcus | last post by:
I'm running into a situation that has me adding a value of "Unknown" to a reference table. I am being pulled between two trains of thought, and was curious to get other's input on in. I give an example below. 1-) Adding "Unknown" to a reference table is bad. Doing so effectively changes the Nullability option of every FK that references the table to a NULLable FK relation. 2-) Simply adding a "Not Known/Undetermined" value to the...
15
2250
by: JKop | last post by:
Does that Standard explicitly forbid the initiation of a null reference? Is there anything wrong with the following code?: void Blah( std::string const &k ) { if ( !&k ) return; // work with k }
102
6115
by: junky_fellow | last post by:
Can 0x0 be a valid virtual address in the address space of an application ? If it is valid, then the location pointed by a NULL pointer is also valid and application should not receive "SIGSEGV" ( i am talking of unix machine ) while trying to read that location. Then how can i distinguish between a NULL pointer and an invalid location ? Is this essential that NULL pointer should not point to any of the location in the virtual address...
6
1784
by: RMD | last post by:
I need to be able to keep a list of object references, and null them out one by one at a later point in time. I realize this can be dangerous, but I have my reasons. I can't figure out, however, how to keep what is essentially a reference to a reference. I want to store my objects in an ArrayList, then loop through the array list and null out the original reference I was given when I added it to my Array List. Below is some example...
5
2184
by: Boniek | last post by:
Hi I define a public property in a new form and I can see this property in table of Properties in Visual. How I can hide this property to see only in code ? Thank's Boniek
2
2087
by: Fei Li | last post by:
Hi, Is null value for a class instance allowed in C#? for example: MyClass obj = null; If Not, how to initiate an instance with value 0? How to detect if an instance is "newed" ? And how to pass a null value to a class constructor whch has a object paramer can be 0? In general, how C# handle a pointer with value 0;
27
4244
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) {
11
3274
by: MikeT | last post by:
This may sound very elementary, but can you trap when your object is set to null within the object? I have created a class that registers an event from an object passed in the constructor. When my object is destroyed, I want my object to un-register this event. If I don't then the object would never be destroyed until the object I passed in the constructor is destroyed. I have implemented a Dispose(), Dispose(bool), and ~Finalize...
76
4737
by: valentin tihomirov | last post by:
As explained in "Using pointers vs. references" http://groups.google.ee/group/borland.public.delphi.objectpascal/browse_thread/thread/683c30f161fc1e9c/ab294c7b02e8faca#ab294c7b02e8faca , the pointers are allowed to be null, while references must refer an existing variable of required type. The null is normally used for making optional parameters. But there is no way to pass null reference in C#. Something is missing.
0
9856
marktang
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...
0
9698
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,...
1
10657
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,...
0
10299
tracyyun
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...
0
9436
agi2029
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...
1
7836
isladogs
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...
0
5684
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4071
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.