Sub ReadBlob 'Reads pic and name from SQL
rs = sql1.ExecQuery("select name, picture from table1")
Dim rowCnt As Int
'Dim returnedPic As Bitmap
Dim InputStream1 As InputStream
Dim Rect As Rect
Dim imgRt As Int
Dim imgBt As Int
Dim xDiv As Int
xDiv = 100%x / 6
rowCnt = 0
flashCards.Width = 4 * xDiv
flashCards.Height = 6 * xDiv
imgRt = flashCards.Left + flashCards.Width
imgBt = flashCards.Top + flashCards.Height
Do While rs.NextRow
rowCnt = rowCnt + 1
If rowCnt = selectedRndRow Then
'Log(rs.GetString("name"))
returnedName = rs.GetString("name")
Buffer = rs.GetBlob("picture")
InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
returnedPic.Initialize2(InputStream1)
'flashCards.Bitmap = returnedPic 'For testing without rotation
canvas1.Initialize(flashCards)
Rect.Initialize(0,0,imgRt,imgBt)
canvas1.DrawBitmapRotated(returnedPic, Rect, 90) 'Rotates image after retrieve from SQL
canvas1.Refresh
InputStream1.Close
End If
Loop
End Sub