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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Studio
  4. Visual Studio odbc commands

Visual Studio odbc commands

Scheduled Pinned Locked Moved Visual Studio
csharpdatabasevisual-studiohelp
4 Posts 3 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.
  • M Offline
    M Offline
    MARKSHAM
    wrote on last edited by
    #1

    I'm trying to pull data into a listbox with more than one column. I have successfully connected to the database from vb.net, and I have pulled data (one column) from using an odbc select command into a list box. The problem I'm having now is that I have more than one column of data that I want to display in the list box. I'm using the following command ListBoxName.Items.Add(myReader.GetString(0)) to get the data into my list box. The "0" indicates the column number that gets inserted into the list box. If I change the number to "1", I can get the second column from my select command to appear in the list box, but I want a multiple column list box with both columns to appear in the list box.

    MSH

    D C 2 Replies Last reply
    0
    • M MARKSHAM

      I'm trying to pull data into a listbox with more than one column. I have successfully connected to the database from vb.net, and I have pulled data (one column) from using an odbc select command into a list box. The problem I'm having now is that I have more than one column of data that I want to display in the list box. I'm using the following command ListBoxName.Items.Add(myReader.GetString(0)) to get the data into my list box. The "0" indicates the column number that gets inserted into the list box. If I change the number to "1", I can get the second column from my select command to appear in the list box, but I want a multiple column list box with both columns to appear in the list box.

      MSH

      D Offline
      D Offline
      Duane in Japan
      wrote on last edited by
      #2

      I really do not know what I am talking about but I just watched a video a little while ago dealing with pulling first names and last names. These two columns of info were concatonated together to fill a full name column. Make a space, not an underscore as my sample??????????? You may not need a literal comma. lastname + "," + _firstname Hope you get some real help from others, I will be watching + learning.

      1 Reply Last reply
      0
      • M MARKSHAM

        I'm trying to pull data into a listbox with more than one column. I have successfully connected to the database from vb.net, and I have pulled data (one column) from using an odbc select command into a list box. The problem I'm having now is that I have more than one column of data that I want to display in the list box. I'm using the following command ListBoxName.Items.Add(myReader.GetString(0)) to get the data into my list box. The "0" indicates the column number that gets inserted into the list box. If I change the number to "1", I can get the second column from my select command to appear in the list box, but I want a multiple column list box with both columns to appear in the list box.

        MSH

        C Offline
        C Offline
        Craster
        wrote on last edited by
        #3

        I'd suggest using a listview instead of a listbox. You can create a listviewitem, set the text property (this will fill the first column of the listview), and for each subsequent column, populate the subitems collection of the listviewitem. If that's not too clear, here's a sample: Dim lv As New ListViewItem lv.Text = sqlrdr.GetString(1) lv.SubItems.Add(sqlrdr.GetString(2)) lv.SubItems.Add(sqlrdr.GetString(3)) ListView1.Items.Add(lv)

        M 1 Reply Last reply
        0
        • C Craster

          I'd suggest using a listview instead of a listbox. You can create a listviewitem, set the text property (this will fill the first column of the listview), and for each subsequent column, populate the subitems collection of the listviewitem. If that's not too clear, here's a sample: Dim lv As New ListViewItem lv.Text = sqlrdr.GetString(1) lv.SubItems.Add(sqlrdr.GetString(2)) lv.SubItems.Add(sqlrdr.GetString(3)) ListView1.Items.Add(lv)

          M Offline
          M Offline
          MARKSHAM
          wrote on last edited by
          #4

          Thanks for the ListView suggestion. I'm new to Visual Studio and OOP, and I have never heard of this option. I will give it a try. Thanks again.

          MSH

          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