Private Sub RetrieveStaffInformation()
CurrentRow = 0
Connection.Open()
Adapter = New OleDbDataAdapter("SELECT Student_Affairs_Officer.* FROM Student_Affairs_Officer ORDER BY ID", Connection)
Adapter.Fill(DTS, "Student_Affairs_Officer")
ShowStaffData(CurrentRow)
Connection.Close()
Dim StaffID As String
Dim i, j As Integer
txtID.Text = Login.txtUsernameORStudentID.Text
StaffID = txtID.Text
j = DTS.Tables("Student_Affairs_Officer").Rows.Count - 1
i = 0
While i <> j + 1
If StaffID = DTS.Tables("Student_Affairs_Officer").Rows(i)("ID") Then
ShowStaffData(i)
End If
i += 1
End While
'Dim Command As New OleDbCommand("SELECT Picture FROM Staff WHERE Staff_ID ='" & txtStaff_ID.Text & "'", Connection)
'Command.Parameters.AddWithValue("@Staff_ID", txtStaff_ID.Text)
'Connection.Open()
'Dim PictureData As Byte() = DirectCast(Command.ExecuteScalar(), Byte())
'Connection.Close()
'Command.Dispose()
'Dim Stream As New IO.MemoryStream(PictureData)
'picStaff.Image = Image.FromStream(Stream)
'Stream.Dispose()
End Sub
Private Sub ShowStaffData(ByVal CurrentRow)
txtID.Text = DTS.Tables("Student_Affairs_Officer").Rows(CurrentRow)("ID")
txtName.Text = DTS.Tables("Student_Affairs_Officer").Rows(CurrentRow)("Full_Name")
PictureBox1.Image = DTS.Tables("Student_Affairs_Officer").Rows(CurrentRow)("Picture")
End Sub
I don't know why I cant retrieve pictures from access database. Can anyone help me?
Firstly, I will login to the system, secondly, after login to the system it will show the name, id and picture of the user. The name and id was complete, no problem, it runs well, but the picture failed to run.