473,394 Members | 1,813 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,394 software developers and data experts.

Best way to check for a null value returned from a database?

Hi, If I have a DataView containing some items and what I want to do is
restore a textbox with an item in one of the rows.

If the item in the datarow is null then obviously I get an error when I try
to bind the item to the textbox
e.g.

uiDelivery.Text = view[0].Row["DeliveryAddress"].ToString();

My question is, what is the best way to test for a null value in C#??

I have seen everything from try catch statements to !=String.Empty() and
==null

Thanks in advance
Mark
Jul 22 '05 #1
2 7081
If IsDBNull(view[0].Row["DeliveryAddress"]) then

Else

End if

or...

if view[0].Row["DeliveryAddress"] = DBNull.value then....

"Mark" <do**@spam.me> wrote in message
news:Ov**************@tk2msftngp13.phx.gbl...
Hi, If I have a DataView containing some items and what I want to do is
restore a textbox with an item in one of the rows.

If the item in the datarow is null then obviously I get an error when I
try
to bind the item to the textbox
e.g.

uiDelivery.Text = view[0].Row["DeliveryAddress"].ToString();

My question is, what is the best way to test for a null value in C#??

I have seen everything from try catch statements to !=String.Empty() and
==null

Thanks in advance
Mark

Jul 22 '05 #2
Thanks Scott
Regards
Mark
"Scott M." <s-***@nospam.nospam> wrote in message
news:O4****************@TK2MSFTNGP14.phx.gbl...
If IsDBNull(view[0].Row["DeliveryAddress"]) then

Else

End if

or...

if view[0].Row["DeliveryAddress"] = DBNull.value then....

"Mark" <do**@spam.me> wrote in message
news:Ov**************@tk2msftngp13.phx.gbl...
Hi, If I have a DataView containing some items and what I want to do is
restore a textbox with an item in one of the rows.

If the item in the datarow is null then obviously I get an error when I
try
to bind the item to the textbox
e.g.

uiDelivery.Text = view[0].Row["DeliveryAddress"].ToString();

My question is, what is the best way to test for a null value in C#??

I have seen everything from try catch statements to !=String.Empty() and
==null

Thanks in advance
Mark


Jul 22 '05 #3

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

Similar topics

20
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
1
by: Luis | last post by:
Is there an easier way to check if any of the fields returned in a select statement have null values? After running this command: set rs = conn.execute("select A,B,C,D,E,F,G,H,I,J from...
4
by: Chuck Ritzke | last post by:
I keep asking myself this question as I write class modules. What's the best/smartest/most efficient way to send a large object back and forth to a class module? For example, say I have a data...
2
by: Pekka Henttonen | last post by:
Forgive me this stupid question, but what is the best way to store the length of an object in a database? What datatype would you use? Would it be better to define one of your own?
6
by: AAVF | last post by:
Hi We have a problem with a query. An Access database links via ODBC to a UNIX server. To speed things, we use the ODBC to load the relevant tables to the local PC that runs Access so that...
0
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET...
2
by: Mark | last post by:
Hi, If I have a DataView containing some items and what I want to do is restore a textbox with an item in one of the rows. If the item in the datarow is null then obviously I get an error when I...
17
by: Mark A | last post by:
DB2 8.2 for Linux, FP 10 (also performs the same on DB2 8.2 for Windoes, FP 11). Using the SAMPLE database, tables EMP and EMLOYEE. In the followng stored procedure, 2 NULL columns (COMM) are...
2
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
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...
0
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...

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.