Table Join in Visual Basic 6 and MS Access

Download
Download is available until [expire_date]
  • Version
  • Download 226
  • File Size 14.19 KB
  • File Count 1
  • Create Date April 28, 2016
  • Last Updated April 28, 2016

Table Join in Visual Basic 6 and MS Access

Table Join in Visual Basic 6 and MS Access

This is a database application in Visual Basic 6 and MS Access that demonstrate how to combine or join two tables and display it as one.

The database has two tables namely tblstudent and tblteacher, now we’re going to show you how to display the records from two tables into one listview.

The table join will display the list of students with their corresponding teacher.

Source code:

Public Sub DisplayJoin()
Dim lstItem As ListItem
If rs.State = adStateOpen Then rs.Close

    sql = " SELECT tblStudent.ID, tblStudent.studentName, tblTeacher.teachername" & _
" FROM tblTeacher LEFT JOIN tblStudent ON tblTeacher.ID = tblStudent.teacherid;"


  rs.Open sql, conn
  ListView3.ListItems.Clear
  Do While Not rs.EOF

        Set lstItem = ListView3.ListItems.Add(, , rs(0).Value)
            lstItem.SubItems(1) = rs(1).Value
           lstItem.SubItems(2) = rs(2).Value
            
            rs.MoveNext
            Loop
End Sub
, , , , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.