IsDBNull


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: IsDBNull

  1. #1
    Beginner Guest

    IsDBNull


    Let's say I have a SQL database with a table where a particular column allows
    nulls. If I populate a DataSet or DataReader object with data from this table,
    how do I determine if a field I'm reading is set to null? For example, in
    VB.NET, I can use the IsDBNull function:

    If IsDBNull(objDataReader.Item("EMail")) = False Then
    Console.Write("EMail is not null")
    Else
    Console.Write("EMail is null")
    End If

    How do I do this in C#?


  2. #2
    Sergey Kats Guest

    Re: IsDBNull

    C# has the same function:
    if (Convert.IsDBNull(objDataReader.Item("EMail")))

    You can also do the following:
    if (objDataReader.Item("EMail") == DBNull.Value)

    or if (objDataReader.IsDBNull(idx))
    where idx is the column index

    Sergey.

    "Beginner" <a@b.c> wrote in message news:3c042467@147.208.176.211...
    >
    > Let's say I have a SQL database with a table where a particular column

    allows
    > nulls. If I populate a DataSet or DataReader object with data from this

    table,
    > how do I determine if a field I'm reading is set to null? For example, in
    > VB.NET, I can use the IsDBNull function:
    >
    > If IsDBNull(objDataReader.Item("EMail")) = False Then
    > Console.Write("EMail is not null")
    > Else
    > Console.Write("EMail is null")
    > End If
    >
    > How do I do this in C#?
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center