-
VB.Net 2008/MySql - Reading Blob image
Good Afternoon,
I wrote a program that stores images into a mysql database blob field. I'm now trying to retrieve that image, I'm having zero luck. We use a scanner that save images as .tif files. I have the following code I'm trying, what do you see wrong?
Any help would be great!!
Dim FileSize As UInt32
Dim rawData() As Byte
Dim conn As MySqlConnection = clsData.OpenMySqlConnection()
Dim reader As MySqlDataReader = Nothing
Dim cmd As New MySqlCommand("SELECT image, filesize FROM scans WHERE ocrid = ?autoid", conn)
cmd.Parameters.AddWithValue("?autoid", strCheckNumber)
reader = cmd.ExecuteReader
reader.Read()
'data is in memory
FileSize = reader.GetUInt32(reader.GetOrdinal("filesize"))
rawData = New Byte(FileSize) {}
'get the bytes and filesize
reader.GetBytes(reader.GetOrdinal("image"), 0, rawData, 0, FileSize)
Dim ms As New System.IO.MemoryStream(FileSize)
ms.Write(rawData, 0, FileSize)
Dim im As Image = Image.FromStream(ms) '* "error occurs here" '(see below)
'pb.Image = im
Dim fs As New FileStream _
("c:\Temp\" & strCheckNumber & ".tif", FileMode.OpenOrCreate, _
FileAccess.Write)
fs.Write(rawData, 0, FileSize)
fs.Close()
Process.Start("\\tsa-acctmysql\scans\Temp\" & strCheckNumber & ".tif")
reader.Close()
conn.Close()
conn.Dispose()
ms.Dispose()
Similar Threads
-
Replies: 2
Last Post: 10-22-2009, 12:39 PM
-
Replies: 12
Last Post: 09-26-2009, 03:46 AM
-
By joshfolgado in forum Database
Replies: 0
Last Post: 07-28-2009, 04:08 AM
-
By JochenKlein in forum Java
Replies: 4
Last Post: 06-02-2006, 05:09 AM
-
By TorrediPisa in forum VB Classic
Replies: 1
Last Post: 10-13-2004, 02:34 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|