Home > Software engineering >  How to use the listview data of the database
How to use the listview data of the database

Time:10-19

I want to use listview1 loading user information in the table (user id user name password)

How to Private Sub LoadData ()
Dim addlist1 As ListItem
'get user information

SQL="select * from user information table order by user id"
Set the rs=SelectSQL (SQL, MSG)
If the rs. RecordCount & lt;> 0 Then
Listview1.=lvwReport 'View report way
Listview1. GridLines=True 'display table lines

Set addlist1=listview1. ColumnHeaders. Add (,, Str (rs) Fields (" user id ")))
//listview1. ColumnHeaders. Add (,, Str (rs) Fields (" user name ")))
//Set addlist1=listview1. ColumnHeaders. Add (,, Str (rs) Fields (" password ")))
//Set addlist1=listview1. ListItems. Add (,, Str (rs) Fields (" id ")))
//addlist1. SubItems (4)=IIf (IsNull (rs) Fields (" phone ")), "", rs. The Fields (" phone"))
All work

Rs. NextRecordset

Listview1. Refresh
End the If
End Sub

CodePudding user response:

What a mess,

No cycle,,,

.
Listview1.=lvwReport 'View report way
Listview1. GridLines=True 'display table lines
Listview1. ColumnHeaders. Add "user id"
Listview1. ColumnHeaders. Add "user name"
.
Dim li As ListItem
While Not rs. Eof
The Set li=listview1. ListItems. Add the rs! The first column
Li. SubItems (0). The Text=rs! The second column
Li. SubItems (1). The Text=rs! The third column
.
Rs. MoveNext
Wend
.
The above code is roughly ideas, write about yourself

CodePudding user response:

Thank you later
  • Related