Private Sub Load_Faculty()
Dim con As New OleDbConnection
Dim cmd As New OleDbCommand
Dim dr As OleDbDataReader
Dim arrImage() As Byte
Dim myMS As New IO.MemoryStream
Dim sSQL As String = String.Empty
Try
sSQL = "SELECT b.FacultyFirstName, b.Image, b.Course, a.Course"
sSQL = sSQL & " FROM studentsrecords as a left join facultynew as b "
sSQL = sSQL & " on a.ID = b.FacultyFirstName WHERE(a.Course = @Course) order by a.Course"
con = New OleDbConnection(Get_Constring)
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.Text
cmd.CommandText = sSQL
' cmd.Parameters.Add("@EvaluationID", OleDbType.DBDate).Value
dr = cmd.ExecuteReader
If dr.HasRows Then
While dr.Read
If Not IsDBNull(dr("Image")) Then
myMS = New IO.MemoryStream
arrImage = dr("Image")
For Each ar As Byte In arrImage
myMS.WriteByte(ar)
Next
End If
Select Case dr("Course")
Case 1
Me.pic1.Tag = dr("FacultyID")
Me.pic1.Image = System.Drawing.Image.FromStream(myMS)
Case 2
Me.pic2.Tag = dr("FacultyID")
Me.pic2.Image = System.Drawing.Image.FromStream(myMS)
Case 3
Me.pic3.Tag = dr("FacultyID")
Me.pic3.Image = System.Drawing.Image.FromStream(myMS)
Case 4
Me.pic4.Tag = dr("FacultyID")
Me.pic4.Image = System.Drawing.Image.FromStream(myMS)
Case 5
Me.pic5.Tag = dr("FacultyID")
Me.pic5.Image = System.Drawing.Image.FromStream(myMS)
Case 6
Me.pic6.Tag = dr("FacultyID")
Me.pic6.Image = System.Drawing.Image.FromStream(myMS)
Case 7
Me.pic7.Tag = dr("FacultyID")
Me.pic7.Image = System.Drawing.Image.FromStream(myMS)
Case 8
Me.pic8.Tag = dr("FacultyID")
Me.pic8.Image = System.Drawing.Image.FromStream(myMS)
Case 9
Me.pic9.Tag = dr("FacultyID")
Me.pic9.Image = System.Drawing.Image.FromStream(myMS)
Case 10
Me.pic10.Tag = dr("FacultyID")
Me.pic10.Image = System.Drawing.Image.FromStream(myMS)
End Select
End While
End If
Catch ex As Exception
MsgBox(ErrorToString)
Finally
con.Close()
End Try
I want to load all faculty
if students course is BSIT
then load all BSIT faculties to the picture box