listview med data fra to tabeller
Hej her er koden til mit listview:Private Sub FillList()
lstBetAftTotal.Clear()
lstBetAftTotal.View = View.Details
Dim cnSQL As OracleConnection
Dim cmSQL As OracleCommand
Dim drSQL As OracleDataReader
Dim strSQL As String
Dim strID As String
strSQL = "select distinct(navn) as navn,sum(antal) as antal from betalingsaftaler where substr(dato,4,2) = '12' and substr(dato,7,10) = '2004' and land = 'DK' group by navn"
cnSQL = New OracleConnection(Util.DBConn())
cnSQL.Open()
cmSQL = New OracleCommand(strSQL, cnSQL)
drSQL = cmSQL.ExecuteReader()
Dim myimage As New ImageList
myimage.Images.Add(Bitmap.FromFile("user2.bmp"))
myimage.Images.Add(Bitmap.FromFile("twouser.bmp"))
lstBetAftTotal.SmallImageList = myimage
'This sets the columns of the ListView to the same column names of the table in the database
With lstBetAftTotal
.Columns.Add(("Navn"), 55, HorizontalAlignment.Left)
.Columns.Add(("Antal"), 40, HorizontalAlignment.Right)
End With
Dim myfont As Font = Me.Font
'Now scrolling through the DataReader and populating the ListView with the data
While drSQL.Read()
Dim ls As New ListViewItem(drSQL.Item("navn").ToString())
ls.UseItemStyleForSubItems = False
ls.SubItems.Add(drSQL.Item("antal").ToString())
ls.ImageIndex = 0
lstBetAftTotal.Items.Add(ls)
End While
lstBetAftTotal.Refresh()
End Sub
hvordan gør jeg hvis datene til min subitems skal hentes fra en anden tabel. Altså listviewet skal indeholde data fra to tabeller. Skal jeg oprette en datareader mere?? Hvis ja, så hvordan?
