Help populating listview with data from mysql
Hi all. i am using the following code to populate my listbox. I wonder how i can modify it so i populate listview instead. My query for listbox outputing one item but for my listview has to output more then one item. I be happy if some one show me how this can be done.Thanks
qury for the listview:
Quote:
select url,author,image,title from videos2
2 Code:
Private Sub Form_Load()
'Open connection
Dim CNN As ADODB.Connection
Dim RS As ADODB.Recordset
Set CNN = New ADODB.Connection
CNN.Open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=test;USER=root;PASSWORD=;OPTION=3;"
'get records to recordset
Set RS = CNN.Execute("select url,author,image,title from videos2", , adCmdText)
'go through all the records until you get to
'the end (rs.EOF = True)
Do Until RS.EOF = True
'Add the records to your listbox
'ShowScrollBar List2.hwnd, SB_HORIZONTAL, True
List2.AddItem RS!URL
'start from the first record and then go through them all
'using .MoveNext
RS.MoveNext
'get all records (loop)
Loop
RS.Close
Set RS = Nothing
CNN.Close
Set CNN = Nothing
'horizantal scroll bar
'List1.AddItem "set the right margin to 3 times the width of the control"
SendMessage List2.hwnd, LB_SETHORIZONTALEXTENT, ScaleX(List2.Width * 3, Me.ScaleMode, vbPixels), 0
ShowScrollBar List2.hwnd, SB_HORIZONTAL, 1
End Sub
Re: Help populating listview with data from mysql
Add Column Headers to the ListView and set its View property to Report.
Code:
Dim oItem as ListItem
Do Until RS.EOF = True
Set oItem = Listview1.ListItems.Add(,,rs.fields("url").Value)
oItem.ListSubItems.Add ,,rs.Fields("author").Value
oItem.ListSubItems.Add ,,rs.Fields("image").Value
oItem.ListSubItems.Add ,,rs.Fields("title").Value
RS.MoveNext
Loop
Re: Help populating listview with data from mysql
thanks brucevde it worked !! could you tell me how to refrence for example the selected first coloum item and place it inside textbox?