Results 1 to 3 of 3

Thread: dbnull in a combobox

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    dbnull in a combobox

    I'm using the code below to fill in a combox. The field can be NULL and I get an error msg when it is. I'm using the code below, but am having a problem on the line where I'm adding string.empty
    (cmbAccount.Items.Add = String.Empty)...do I have this coded right?



    VB Code:
    1. Do While objDR.Read = True
    2.                     If (objDR("vendor_name")) Is DBNull.Value Then
    3.                         cmbAccount.Items.Add = String.Empty
    4.                     Else
    5.                         Me.cmbAccount.Items.Add(RTrim(objDR("vendor_name")))
    6.                     End If
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    What's the error ? I suppose it's in the Add part of the cmbAccount object .

    Try this code :
    VB Code:
    1. Do While objDR.Read = True
    2.                     If (objDR("vendor_name")) Is DBNull.Value Then
    3.                         cmbAccount.Items.Add[B](String.Empty)[/B]  
    4.                     Else
    5.                         Me.cmbAccount.Items.Add(RTrim(objDR("vendor_name")))
    6.                     End If

  3. #3

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    thanks Pirate
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

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