Hi! Im developing a web application that reads from a database and populate a
form with a DataReader. When the reader reach a null value in the database,
the application throws an exception. In VB I used the IsDBNull function to
catch and process the null values.
Is there a similar function in C#???
Thanks!!!
Raul 9 10675
Raul M. Colon wrote: Hi! Im developing a web application that reads from a database and populate a form with a DataReader. When the reader reach a null value in the database, the application throws an exception. In VB I used the IsDBNull function to catch and process the null values.
Is there a similar function in C#???
Thanks!!!
Raul
Why wouldn't you just check if returned value is null?
while (reader.Read())
{
if (reader.getValue(<column_number>) == null)
{<...do whatever...>}
}
Good luck,
Andrey aka Muzzy
> ... In VB I used the IsDBNull function to catch and process the null values.
Is there a similar function in C#???
Yes. Just compare the value to DBNull.Value to check if it is a null value.
Anders Norås http://dotnetjunkies.com/weblog/anoras/
Anders Norås [MCAD] wrote: ... In VB I used the IsDBNull function to catch and process the null values.
Is there a similar function in C#???
Yes. Just compare the value to DBNull.Value to check if it is a null value.
Anders Norås http://dotnetjunkies.com/weblog/anoras/
Do you need to check against DBNull.Value if you use DataReader?
If a value is null, then DataReader.GetValue() returns just null...
Am i missing something here?
Thank you,
Andrey
On Mon, 27 Dec 2004 17:06:25 -0500, MuZZy wrote: Why wouldn't you just check if returned value is null?
while (reader.Read()) { if (reader.getValue(<column_number>) == null) {<...do whatever...>} }
Because null != DBNull. You can either compare to DBNull.Value, or more
familiar to VB programmers maybe would be to use Convert.IsDBNull.
--
Tom Porterfield
I was the one missing the point. Thanks for your replies, the combination of
if(reader.GetValue == DBNull.Value)
{ .....
}
worked fine. Thanks!!!
"MuZZy" wrote: Anders Norås [MCAD] wrote:... In VB I used the IsDBNull function to catch and process the null values.
Is there a similar function in C#???
Yes. Just compare the value to DBNull.Value to check if it is a null value.
Anders Norås http://dotnetjunkies.com/weblog/anoras/
Do you need to check against DBNull.Value if you use DataReader? If a value is null, then DataReader.GetValue() returns just null...
Am i missing something here?
Thank you, Andrey
Tom, Because null != DBNull. You can either compare to DBNull.Value, or more familiar to VB programmers maybe would be to use Convert.IsDBNull.
In my opinion the same as C# however using than the IS operator (when you
are talking about VBNet).
Cor
Raul M. Colon <Ra********@discussions.microsoft.com> wrote: Hi! Im developing a web application that reads from a database and populate a form with a DataReader. When the reader reach a null value in the database, the application throws an exception. In VB I used the IsDBNull function to catch and process the null values.
Is there a similar function in C#???
Another possibility no-one has mentioned is not to fetch the value, but
to use the IsDBNull method on the DataReader, specifying the
appropriate column.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
null is C# syntax for determining if an instance variable is not initialized
or not currently pointing to an actual object. That is not the same thing
as database NULLness, which has a completely different meaning -- it
signifies an unknown value, not an undefined object reference.
--Bob
"MuZZy" <le*******@yahoo.com> wrote in message
news:tq********************@rcn.net... Raul M. Colon wrote: Hi! Im developing a web application that reads from a database and populate a form with a DataReader. When the reader reach a null value in the database, the application throws an exception. In VB I used the IsDBNull function to catch and process the null values.
Is there a similar function in C#???
Thanks!!!
Raul
Why wouldn't you just check if returned value is null?
while (reader.Read()) { if (reader.getValue(<column_number>) == null) {<...do whatever...>} } Good luck, Andrey aka Muzzy
On Mon, 27 Dec 2004 13:55:03 -0800, Raul M. Colon wrote: Hi! Im developing a web application that reads from a database and populate a form with a DataReader. When the reader reach a null value in the database, the application throws an exception. In VB I used the IsDBNull function to catch and process the null values.
Is there a similar function in C#???
Thanks!!!
Raul
if(reader["fieldName"] is DbNull)
{
//Do something
}
/Hugo This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Thomas Coleman |
last post by:
I have been playing around with 2.0 and I'm trying clarify a few things about
generics and data access. I was hoping to be able to do something like this with
nullable types:
int? foo = null;
...
|
by: spshealy |
last post by:
Greetings,
I have a question about how nulls are handled in "IN" clauses.. I
understand the operation null = anyvalue is undefined. Please examine
the following example.
drop table one...
|
by: jt |
last post by:
I can't seem to find a way to concatenate strings that have nulls within the
string.
I have a string that I need another string that has nulls in it and what to
append
the 2nd string, 3 string...
|
by: Vagabond Software |
last post by:
Apparently, the Split method handles consecutive tabs as a single delimiter. Does anyone have any suggestions for handling consecutive tabs?
I am reading in text files that contain lines of...
|
by: tshad |
last post by:
I have people telling me that I should set up objects for my tables, but I
am finding the Null problem makes that difficult.
It isn't a big problem if you are not updating the table, but if you...
|
by: AAJ |
last post by:
Hi
Does anyone know of any good publically available set of standards for
managing dates when dealing with a database server (in my case SQL Server
2000 and c# VS2005).
At the moment, if I...
|
by: CharlesL |
last post by:
I am trying to handle binary strings in php. I get a binary output
initialization vector from mcrypt as such:
from mcrypt:
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
This output may have...
|
by: Zytan |
last post by:
Ok something simple like int.Parse(string) can throw these exceptions:
ArgumentNullException, FormatException, OverflowException
I don't want my program to just crash on an exception, so I must...
|
by: Cliff72 |
last post by:
I need to fill in the nulls in the batch field the value from the
record immediately
preceding the null one ie replace the nulls with the preceding value
until I hit a record with a value in...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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: 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,...
| |