Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. null field into Listview

null field into Listview

Scheduled Pinned Locked Moved Visual Basic
questiondatabase
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jaydeanster
    wrote on last edited by
    #1

    Hello all, How do I supplement the code below so that when a subitem is null from the database, the field in the listview is populated with a string; such as "n/a"? There will be occasions when a field(s) corresponding to a subitem(s) might be null. ///////////////////// Public Sub FillListView() Dim fieldCtr As Short Dim rdlv As SqlDataReader rdlv = sqlCmd.ExecuteReader Do While rdlv.Read lvItems = New ListViewItem lvItems.Text = Trim(rdlv(0)) For fieldCtr = 1 To rdlv.FieldCount() - 1 If rdlv.IsDBNull(fieldCtr) Then lvitems.SubItems.Add("") Else lvitems.SubItems.Add(rdlv.GetString(1)) lvitems.SubItems.Add(rdlv.GetString(2)) lvitems.SubItems.Add(rdlv.GetString(3)) lvitems.SubItems.Add(rdlv.GetString(4)) lvitems.SubItems.Add(rdlv.GetString(5)) lvitems.SubItems.Add(rdlv.GetString(6)) lvitems.SubItems.Add(rdlv.GetDateTime(7)) 'lvItems.SubItems.Add(rdlv.GetDateTime(8)) End If Next fieldCtr Me.lvSearchProperty.Items.Add(lvItems) Loop Me.btnSubmit.Enabled = False End Sub //////////////// Thanks a bunch, Jaydeanster Ben, is that you?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups