473,404 Members | 2,137 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,404 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 7082
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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...
0
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,...
0
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...

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.