VB6 fill a ListBox

I cannot figure out why my ListBox won't display the values pulled from my MySQL table.  Table contains 12 rows of data and the select statement works directly in SQL Server.

This routine is called upon form load.
Private Sub fLoadGuiParmList()
    Dim fsCmd As String
    Dim fsName As String
 
    Call lstGuiParm.Clear
    fsCmd = ""
    fsCmd = fsCmd & "SELECT  * "
    fsCmd = fsCmd & "FROM   GuiParmList "
    fsCmd = fsCmd & "ORDER  BY ParmNm "
   
    Set goRecSet = goConn.Execute(fsCmd)
    If Not goRecSet.EOF Then
        goRecSet.MoveFirst
        While Not goRecSet.EOF
            fsName = goRecSet("ParmNm")
            Call lstGuiParm.AddItem(fsName)
            goRecSet.MoveNext
        Wend
    End If
    lstGuiParm.ListIndex = 0
End Sub

Open in new window

kkbenjAsked:
Who is Participating?
 
Éric MoreauSenior .Net ConsultantCommented:
I am not sure if I remember correctly but wasn't there something about the kind of recordset opened with Execute?

Can you try this:

    Set goRecSet = goConn.Execute(fsCmd)
'    If Not goRecSet.EOF Then
'        goRecSet.MoveFirst
        While Not goRecSet.EOF
            fsName = goRecSet("ParmNm")
            Call lstGuiParm.AddItem(fsName)
            goRecSet.MoveNext
        Wend
 '   End If
0
 
kkbenjAuthor Commented:
emoreau -
I use this loop elsewhere in my code and it works.  I did try yours anyway and there is no difference.
0
 
Éric MoreauSenior .Net ConsultantCommented:
is there something wrong with your connection object then?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
kkbenjAuthor Commented:
no, other loops fill Combo boxes fine.  The difference is this is a list box.
0
 
HooKooDooKuCommented:
Stupid question, but have you tried stepping through the code to prove that there are records to process?

emoreau is pointing out that when you open a recordset you don't have to use .MoveFirst, the recordset will get initialized pointing to the 1st record.  You only need to use MoveFirst if you need to return to the beginning of the record set.

Another stupid question.  What sort of value is "ParmNm", or more specific, what is in it.  Is it possible that the "value" of this field is equating to a blank string?
0
 
kkbenjAuthor Commented:
HooKooDooKu - no stupid questions where I'm concerned.  I did not step thru the code, but there are values picked up.  It's simply a character field in the db.  BUT immediately after filling the box, a clear command is issued in another setup.  OOPS!

emoreau - thank you for your explanation of MoveFirst and the correct time to use it.  It's been ages (as you can tell) since I've done VB.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.