Results 1 to 3 of 3

Thread: Handling nulls from database query

Threaded View

  1. #1

    Thread Starter
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651

    Handling nulls from database query

    Hi

    In VB6 you would handle null columns as follows:
    VB Code:
    1. Dim lcStrValue as string
    2. Dim lcObjRcs as ADODB.Recordset
    3.  
    4. lcStrValue = "" &  lcObjRcs!Surname

    I am now using VB.NET and picking up values from a DataRow object and getting an exception about DBNull.

    How do I handle Null in the code below assuming the Surname column in the table is null.


    VB Code:
    1. Dim oDataRow As DataRow
    2.  
    3. For Each oDataRow in dtTable.Rows
    4.     strSurname = oDataRow.Item("Surname")
    5. Next

    Thanks
    Last edited by Mr.No; May 3rd, 2004 at 05:31 AM.
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width