-
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#?
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks