Обсуждение: Detecting a Null field on an NpgsqlDataReader object

Поиск
Список
Период
Сортировка

Detecting a Null field on an NpgsqlDataReader object

От
"Oliveiros d'Azevedo Cristina"
Дата:
Dear All,
 
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?
 
Thanks a million for your help
 
Best,
Oliveiros d'Azevedo Cristina

Re: Detecting a Null field on an NpgsqlDataReader object

От
"Francisco Figueiredo Jr."
Дата:
On Tue, Aug 3, 2010 at 12:25, Oliveiros d'Azevedo Cristina
<oliveiros.cristina@marktest.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


Re: Detecting a Null field on an NpgsqlDataReader object

От
"Oliveiros d'Azevedo Cristina"
Дата:
Olá!

>> 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.
>
>

Oh, I see.
All in all it's the same mechanism .
Yes, I'm indeed trying to check in a NpgsqlDataReader.
I'll give that method a try.



Obrigado,
Oliveiros 



Re: Detecting a Null field on an NpgsqlDataReader object

От
"Francisco Figueiredo Jr."
Дата:
On Tue, Aug 3, 2010 at 13:46, Oliveiros d'Azevedo Cristina
<oliveiros.cristina@marktest.pt> wrote:
> Olá!
>

Olá! Tudo bem?

>>> 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.
>>
>>
>
> Oh, I see.
> All in all it's the same mechanism .
> Yes, I'm indeed trying to check in a NpgsqlDataReader.
> I'll give that method a try.
>

If you need any help, please let us know.

>
>
> Obrigado,

De nada!


--
Regards,

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