Skip site navigation (1) Skip section navigation (2)

Re: Detecting a Null field on an NpgsqlDataReader object

From: "Francisco Figueiredo Jr(dot)" <francisco(at)npgsql(dot)org>
To: "Oliveiros d'Azevedo Cristina" <oliveiros(dot)cristina(at)marktest(dot)pt>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Detecting a Null field on an NpgsqlDataReader object
Date: 2010-08-03 16:32:01
Message-ID: AANLkTimasvLEGs84qy3X+tHBEqQGACYtZAR3T4zpu9tw@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-interfaces
On Tue, Aug 3, 2010 at 12:25, Oliveiros d'Azevedo Cristina
<oliveiros(dot)cristina(at)marktest(dot)pt> wrote:
> Dear All,
>

Hi!

> How can I detect if a certain field of a record returned by a query is NULL
> ?
>
> I'm sure there must be a direct way of doing this, but I googled up and
> down, back and forth and was unable to find out.
>
> For ex, in Sql Server we just compare with DbNull singleton.
>
> What is the equivalent in Npgsql?
>

You can use the same way. Npgsql uses DBNull singleton to express null values.
If you are trying to check in the NpgsqlDataReader, you will need to
use the method IsDBNull(int)

I hope it helps.


-- 
Regards,

Francisco Figueiredo Jr.
Npgsql Lead Developer
http://www.npgsql.org
http://fxjr.blogspot.com
http://twitter.com/franciscojunior

In response to

Responses

pgsql-interfaces by date

Next:From: Oliveiros d'Azevedo CristinaDate: 2010-08-03 16:46:54
Subject: Re: Detecting a Null field on an NpgsqlDataReader object
Previous:From: Oliveiros d'Azevedo CristinaDate: 2010-08-03 15:25:57
Subject: Detecting a Null field on an NpgsqlDataReader object

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group