473,668 Members | 2,386 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking for null

I'm getting this error...Operato r is not valid for type 'DBNull' and string
"". What is happening is that I'm calling a stored procedure to use the
email address to recover a forgotten username. If the email does not exist
then I get the above error. After I execute the stored procedure I try and
apparenty this is not catching the error. Should I use a Try...Catch? What
is the correct way to check for nulls in ASP.NET?

If Not myCommand.Param eters("@LOGIN_N AME").Value = "" Then

returnLogin = myCommand.Param eters("@LOGIN_N AME").Value

Else

lblMessage.Text = "Email does not exist in system. Re-enter email or contact
BRM Support"

End If


Nov 18 '05 #1
5 1786
Just a guess but have you tried IsNothing?

If IsNothing(yadda ) = True Then
Do Something
End If
"Andy G" <aj*****@iastat e.edu> wrote in message
news:OH******** *****@TK2MSFTNG P10.phx.gbl...
I'm getting this error...Operato r is not valid for type 'DBNull' and
string
"". What is happening is that I'm calling a stored procedure to use the
email address to recover a forgotten username. If the email does not
exist
then I get the above error. After I execute the stored procedure I try
and
apparenty this is not catching the error. Should I use a Try...Catch?
What
is the correct way to check for nulls in ASP.NET?

If Not myCommand.Param eters("@LOGIN_N AME").Value = "" Then

returnLogin = myCommand.Param eters("@LOGIN_N AME").Value

Else

lblMessage.Text = "Email does not exist in system. Re-enter email or
contact
BRM Support"

End If

Nov 18 '05 #2
I tried this and I still get the same error. Checking for null should not
be this difficult. Any other ideas?

If IsNothing(myCom mand.Parameters ("@LOGIN_NAME") .Value) = True Then

returnLogin = myCommand.Param eters("@LOGIN_N AME").Value

Else

lblMessage.Text = "Email does not exist in system. Re-enter email or contact
BRM Support"

End If

"D. Shane Fowlkes" <sh**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Just a guess but have you tried IsNothing?

If IsNothing(yadda ) = True Then
Do Something
End If
"Andy G" <aj*****@iastat e.edu> wrote in message
news:OH******** *****@TK2MSFTNG P10.phx.gbl...
I'm getting this error...Operato r is not valid for type 'DBNull' and
string
"". What is happening is that I'm calling a stored procedure to use the email address to recover a forgotten username. If the email does not
exist
then I get the above error. After I execute the stored procedure I try
and
apparenty this is not catching the error. Should I use a Try...Catch?
What
is the correct way to check for nulls in ASP.NET?

If Not myCommand.Param eters("@LOGIN_N AME").Value = "" Then

returnLogin = myCommand.Param eters("@LOGIN_N AME").Value

Else

lblMessage.Text = "Email does not exist in system. Re-enter email or
contact
BRM Support"

End If


Nov 18 '05 #3
Hmmm...another guess. Have you tried IsDBNull?

If IsDBNull(databa se field here) = False Then
do something
End If


"Andy G" <aj*****@iastat e.edu> wrote in message
news:OP******** ******@TK2MSFTN GP09.phx.gbl...
I tried this and I still get the same error. Checking for null should not
be this difficult. Any other ideas?

If IsNothing(myCom mand.Parameters ("@LOGIN_NAME") .Value) = True Then

returnLogin = myCommand.Param eters("@LOGIN_N AME").Value

Else

lblMessage.Text = "Email does not exist in system. Re-enter email or
contact
BRM Support"

End If

"D. Shane Fowlkes" <sh**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Just a guess but have you tried IsNothing?

If IsNothing(yadda ) = True Then
Do Something
End If
"Andy G" <aj*****@iastat e.edu> wrote in message
news:OH******** *****@TK2MSFTNG P10.phx.gbl...
> I'm getting this error...Operato r is not valid for type 'DBNull' and
> string
> "". What is happening is that I'm calling a stored procedure to use the > email address to recover a forgotten username. If the email does not
> exist
> then I get the above error. After I execute the stored procedure I try
> and
> apparenty this is not catching the error. Should I use a Try...Catch?
> What
> is the correct way to check for nulls in ASP.NET?
>
> If Not myCommand.Param eters("@LOGIN_N AME").Value = "" Then
>
> returnLogin = myCommand.Param eters("@LOGIN_N AME").Value
>
> Else
>
> lblMessage.Text = "Email does not exist in system. Re-enter email or
> contact
> BRM Support"
>
> End If
>
>
>
>



Nov 18 '05 #4
IsDBNull will and should work!
GDLUCK
PAtrick
"Andy G" wrote:
I tried this and I still get the same error. Checking for null should not
be this difficult. Any other ideas?

If IsNothing(myCom mand.Parameters ("@LOGIN_NAME") .Value) = True Then

returnLogin = myCommand.Param eters("@LOGIN_N AME").Value

Else

lblMessage.Text = "Email does not exist in system. Re-enter email or contact
BRM Support"

End If

"D. Shane Fowlkes" <sh**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Just a guess but have you tried IsNothing?

If IsNothing(yadda ) = True Then
Do Something
End If
"Andy G" <aj*****@iastat e.edu> wrote in message
news:OH******** *****@TK2MSFTNG P10.phx.gbl...
I'm getting this error...Operato r is not valid for type 'DBNull' and
string
"". What is happening is that I'm calling a stored procedure to use the email address to recover a forgotten username. If the email does not
exist
then I get the above error. After I execute the stored procedure I try
and
apparenty this is not catching the error. Should I use a Try...Catch?
What
is the correct way to check for nulls in ASP.NET?

If Not myCommand.Param eters("@LOGIN_N AME").Value = "" Then

returnLogin = myCommand.Param eters("@LOGIN_N AME").Value

Else

lblMessage.Text = "Email does not exist in system. Re-enter email or
contact
BRM Support"

End If



Nov 18 '05 #5
Thanks! IsDBNull worked in addition to a little thing I forgot. I added
Exit Sub inside the condition, otherwise it would redirect which I didn't
want it to do.
"Patrick.O. Ige" <Pa*********@di scussions.micro soft.com> wrote in message
news:0D******** *************** ***********@mic rosoft.com...
IsDBNull will and should work!
GDLUCK
PAtrick
"Andy G" wrote:
I tried this and I still get the same error. Checking for null should not be this difficult. Any other ideas?

If IsNothing(myCom mand.Parameters ("@LOGIN_NAME") .Value) = True Then

returnLogin = myCommand.Param eters("@LOGIN_N AME").Value

Else

lblMessage.Text = "Email does not exist in system. Re-enter email or contact BRM Support"

End If

"D. Shane Fowlkes" <sh**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Just a guess but have you tried IsNothing?

If IsNothing(yadda ) = True Then
Do Something
End If
"Andy G" <aj*****@iastat e.edu> wrote in message
news:OH******** *****@TK2MSFTNG P10.phx.gbl...
> I'm getting this error...Operato r is not valid for type 'DBNull' and
> string
> "". What is happening is that I'm calling a stored procedure to use
the
> email address to recover a forgotten username. If the email does

not > exist
> then I get the above error. After I execute the stored procedure I try > and
> apparenty this is not catching the error. Should I use a Try...Catch? > What
> is the correct way to check for nulls in ASP.NET?
>
> If Not myCommand.Param eters("@LOGIN_N AME").Value = "" Then
>
> returnLogin = myCommand.Param eters("@LOGIN_N AME").Value
>
> Else
>
> lblMessage.Text = "Email does not exist in system. Re-enter email or
> contact
> BRM Support"
>
> End If
>
>
>
>


Nov 18 '05 #6

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

Similar topics

8
18674
by: Dave Robinson | last post by:
I was wondering if anyone could help me with a problem I'm having. I've been using Dreamweaver to create a hotel booking system for a friend of mine, using MySQL (version 4.0.21) and PHP 5. The bit I'm struggling with is checking the Room Availability based on dates that are typed into a textfield and then returning a list of the available rooms on the next page. The three tables involved in this function are: CREATE TABLE `room` (
30
2232
by: Michael B Allen | last post by:
I have a general purpose library that has a lot of checks for bad input parameters like: void * linkedlist_get(struct linkedlist *l, unsigned int idx) { if (l == NULL) { errno = EINVAL; return NULL; }
99
5132
by: Mikhail Teterin | last post by:
Hello! Consider the following simple accessor function: typedef struct { int i; char name; } MY_TYPE; const char *
2
3402
by: Chris | last post by:
Hi, I have an SQL Query that loads a SQLDataReader object. The returned record has bit datatype columns that I use to provide true/false values. I can't get a definite answer googling on how to test if this field is null. I get casting errors, and can't check for null on a null data value errors
5
5782
by: A.M | last post by:
Hi, To check if QueryString contains a key I compaire it with null like this code: if (Request.QueryString!=null) { Label1.Text= Request.QueryString; } else
4
2374
by: Patient Guy | last post by:
Does anyone have any coding rules they follow when doing argument checking? When arguments fail during check, do you return from the call with an ambiguous return value, or do you throw exceptions?
2
7408
by: Venkata Narayana | last post by:
Hi, You all may be knowing that Connection.isClosed() does not tells us if the underying DB connection is active or not; it only checks if Connection.close() had been previously called or not. One sure shot way to find out this is by executing some dummy SELECT query and catching it via SQLException. This could be done in various DB's as follows: SELECT * from 1 (MS SQL) SELECT * from DUAL(Oracle)
13
2497
by: Karch | last post by:
I find myself doing things like this all the time: if ( SomeObject != null && SomeObject.AnotherObject != null && SomeObject.AnotherObject.YetAnother != null && SomeObject.AnotherObject.YetAnother.HelpMePlease != null) { // Do Something }
51
4203
by: atv | last post by:
Hi, Just to check, if i set a pointer explicitly to NULL, i'm not allowed to dereference it? Why is that, it's not like it's pointing to any garbage right? Why else set it to NULL. I can remember some instances where i did just that and printf reported something like : (null). I'm asking because i read somewhere that it is not valid. I thought it simply wasn't valid to dereference a pointer who is _not_ set to point to anything.
1
2107
by: kannan1983 | last post by:
In a table i have to check each and every column for null values . if the column has null value i need to display as ' NULL VALUE' in the output , for these iam declaring some local variables Iam checking the column for null value using IF ( col_name IS NULL) if the column has null value ill assign the variable as null value or else ill assign the value which is there in the column another thing we can use NVL2 function to do the same...
0
8459
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
8378
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,...
0
8890
Oralloy
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...
0
8653
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
7398
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
6206
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
4202
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...
0
4376
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2018
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.