Results 1 to 4 of 4

Thread: List Box in vb2005

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    127

    List Box in vb2005

    Hi All,

    I am trying to upgrade my existing vb6 project to vb2005.
    In vb6 i was using


    strQuery = "select * from tblemployee order by emp_name"
    Set rstRecord = gObjConn.Execute(strQuery)

    While Not rstRecord.EOF

    lstLookup.AddItem rstRecord("emp_name")
    lstLookup.ItemData(lstLookup.NewIndex) = rstRecord("emp_id")
    rstRecord.MoveNext
    Wend

    How can i do the same using vb2005


    Thnks

  2. #2
    Registered User RaviIntegra's Avatar
    Join Date
    Mar 2007
    Location
    Pondicherry, India
    Posts
    125

    Re: List Box in vb2005

    vb Code:
    1. 'Use this code to get the data from your database
    2.         Dim con As New OleDb.OleDbConnection("type your connection string")
    3.         con.Open()
    4.         Dim da As New OleDb.OleDbDataAdapter("select * from tblTest", con)
    5.         Dim dt As New DataTable
    6.         Dim ret As Integer = da.Fill(dt)
    7.         If ret > 0 Then
    8.             For i As Integer = 0 To ret - 1
    9.                 ListBox1.Items.Add(dt.Rows(i).Item("fieldname"))
    10.             Next
    11.         End If

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    127

    Re: List Box in vb2005

    Where the index setting like we do in vb6 lstLookup.ItemData(lstLookup.NewIndex) = rstRecord("emp_id")

  4. #4
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853
    Please mark you thread resolved using the Thread Tools as shown

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