Sub ReadPhoto
Dim strSQL As String = "SELECT Photo, DATALENGTH(Photo) as Size, Thumbnail FROM Pass WHERE ResID = ? AND ResDetID = ? AND Line = ?"
Dim rs As ResultSet
'reset the imageviews
imgPhoto.SetImage(Null)
imgThumbnail.SetImage(Null)
ImgPreview.SetImage(Null)
DBConnect
If Connected Then
rs = sql.ExecQuery2(strSQL,Array As String(ResID, ResDetID,LineNo))
rs.NextRow
Dim Buffer() As Byte
Buffer = rs.GetBlob2(0)
'load Photo image
If Buffer <> Null Then
Dim Inputstream1 As InputStream
Inputstream1.InitializeFromBytesArray(Buffer,0,Buffer.Length)
If Inputstream1.BytesAvailable > 0 Then
Dim img As Image
img.Initialize2(Inputstream1)
Inputstream1.Close
imgPhoto.SetImage(img)
imgThumbnail.SetImage(img) 'as you suggested
imgThumbnail.Snapshot 'as you suggested
End If
End If
Dim PrevBuffer() As Byte
PrevBuffer = rs.GetBlob2(2)
'load Thumbnail to ImgPreview ImageView, to confirm what was saved to the db prior in the btnSave2DB_Click handler - see Post#5
If PrevBuffer <> Null Then
Dim in As InputStream
in.InitializeFromBytesArray(PrevBuffer,0,PrevBuffer.Length)
Dim PrevImg As Image
PrevImg.Initialize2(in)
in.Close
ImgPreview.SetImage(PrevImg)
End If
End If
DBDisconnect
End Sub