Menu

#106 Unable to return LargeBlob data

open
nobody
None
5
2004-04-18
2004-04-18
Anonymous
No

Writing a vb .net app that will store and view images
stored in a MySql database. Able to store the images
using a LargeBlob value type. Same error for
MediumBlob as well.

Only get error when returning large data return. If the
Image returned would small, that would fit into a Blob
data field. It would return fine. If the data is larger the
what would fit in a Blob, get error.

I am able to view the image using MySQL-Front. Image
is stored fine.

Error:
Arithmetic operation resulted in an overflow.
at ByteFX.Data.MySqlClient.MySqlField.CopyBuffer()
at ByteFX.Data.MySqlClient.MySqlField.GetValue()
at ByteFX.Data.MySqlClient.MySqlField.GetValue(Int32 i)
at ShowImage(Object ImageData) in line 63

Table:
Image_ID as Integer
Image_Data as LargeBlob

SourceCode:
Public Function ShowImage(ByVal ImageData) As
Image
Try
Dim strSQL As String = "Select Image_ID,
Image_Data from ImageTable Where Image_ID = " &
ImageData

Dim dbcon As IDbConnection = New
MySqlConnection(MyConString)
dbcon.Open()
Dim dbcmd As IDbCommand =
dbcon.CreateCommand
dbcmd.CommandText = strSQL
Dim reader As IDataReader =
dbcmd.ExecuteReader
reader.Read()

Dim byteBLOBData(-1) As [Byte]
byteBLOBData = CType(reader.GetValue(1),
[Byte]())
Dim stmBLOBData As New MemoryStream
(byteBLOBData)
ShowImage = Image.FromStream(stmBLOBData)

'Clean up
reader.Close()
reader = Nothing
dbcmd.Dispose()
dbcmd = Nothing
dbcon.Close()
dbcon = Nothing

Catch ex As Exception
MessageBox.Show(ex.StackTrace)
End Try
End Function

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.