473,387 Members | 1,416 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Checking for null

I'm getting this error...Operator 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.Parameters("@LOGIN_NAME").Value = "" Then

returnLogin = myCommand.Parameters("@LOGIN_NAME").Value

Else

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

End If


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

If IsNothing(yadda) = True Then
Do Something
End If
"Andy G" <aj*****@iastate.edu> wrote in message
news:OH*************@TK2MSFTNGP10.phx.gbl...
I'm getting this error...Operator 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.Parameters("@LOGIN_NAME").Value = "" Then

returnLogin = myCommand.Parameters("@LOGIN_NAME").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(myCommand.Parameters("@LOGIN_NAME").Valu e) = True Then

returnLogin = myCommand.Parameters("@LOGIN_NAME").Value

Else

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

End If

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

If IsNothing(yadda) = True Then
Do Something
End If
"Andy G" <aj*****@iastate.edu> wrote in message
news:OH*************@TK2MSFTNGP10.phx.gbl...
I'm getting this error...Operator 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.Parameters("@LOGIN_NAME").Value = "" Then

returnLogin = myCommand.Parameters("@LOGIN_NAME").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(database field here) = False Then
do something
End If


"Andy G" <aj*****@iastate.edu> wrote in message
news:OP**************@TK2MSFTNGP09.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(myCommand.Parameters("@LOGIN_NAME").Valu e) = True Then

returnLogin = myCommand.Parameters("@LOGIN_NAME").Value

Else

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

End If

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

If IsNothing(yadda) = True Then
Do Something
End If
"Andy G" <aj*****@iastate.edu> wrote in message
news:OH*************@TK2MSFTNGP10.phx.gbl...
> I'm getting this error...Operator 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.Parameters("@LOGIN_NAME").Value = "" Then
>
> returnLogin = myCommand.Parameters("@LOGIN_NAME").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(myCommand.Parameters("@LOGIN_NAME").Valu e) = True Then

returnLogin = myCommand.Parameters("@LOGIN_NAME").Value

Else

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

End If

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

If IsNothing(yadda) = True Then
Do Something
End If
"Andy G" <aj*****@iastate.edu> wrote in message
news:OH*************@TK2MSFTNGP10.phx.gbl...
I'm getting this error...Operator 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.Parameters("@LOGIN_NAME").Value = "" Then

returnLogin = myCommand.Parameters("@LOGIN_NAME").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*********@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.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(myCommand.Parameters("@LOGIN_NAME").Valu e) = True Then

returnLogin = myCommand.Parameters("@LOGIN_NAME").Value

Else

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

End If

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

If IsNothing(yadda) = True Then
Do Something
End If
"Andy G" <aj*****@iastate.edu> wrote in message
news:OH*************@TK2MSFTNGP10.phx.gbl...
> I'm getting this error...Operator 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.Parameters("@LOGIN_NAME").Value = "" Then
>
> returnLogin = myCommand.Parameters("@LOGIN_NAME").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
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...
30
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;...
99
by: Mikhail Teterin | last post by:
Hello! Consider the following simple accessor function: typedef struct { int i; char name; } MY_TYPE; const char *
2
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...
5
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
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...
2
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....
13
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 &&...
51
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...
0
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,...
0
jinu1996
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 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.