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
我不知道为什么我无法从访问数据库中检索图片。任何人都可以帮助我吗?
首先,我将登录系统,其次,登录系统后,将显示用户的名称,ID和图片。名称和ID完整,没问题,运行良好,但图片无法运行。