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 5 1759
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
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
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
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
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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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
}
|
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...
|
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...
| |
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
|
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;
|
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: 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...
|
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.
|
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: 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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: 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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
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...
|
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
| |