Re: Storing/Retrieving BLOB Data directly into a PictureBox in VB.NET
Posted by: Andy Pratt
Date: January 31, 2007 04:08PM

I am so sure there is a simple solution to this problem. Something to do with bandwidth alowance on the Mysqlserver or something i need to add to the connection string but the problem is as follows:

Using the below code works great until the file size gets roughly above 1meg then i get the following error "Unable to Write to Stream"

I thought that maybe there was something wrong with the filestream as the error would imply but i can happily write huge files too and from rawdata and into system files again so it has led me to think something was up elsewhere but i just can't seem to get it.

Any advice would be GREATLY apreciated.

Thanks in advance,

Dim conn As New MySqlConnection
Dim cmd As New MySqlCommand

Dim SQL As String

Dim FileSize As UInt32
Dim rawData() As Byte
Dim fs As FileStream

conn.ConnectionString = "server=;" _
& "uid=root;" _
& "pwd=******;" _
& "database=******"

fs = New FileStream(fileDirectoryopen, FileMode.Open, FileAccess.Read)
FileSize = fs.Length

rawData = New Byte(FileSize) {}
fs.Read(rawData, 0, FileSize)


SQL = "INSERT INTO file VALUES(NULL, ?FileName, ?FileSize, ?File)"

cmd.Connection = conn
cmd.CommandText = SQL
cmd.Parameters.Add("?FileName", fileDirectoryopen)
cmd.Parameters.Add("?FileSize", FileSize)
cmd.Parameters.Add("?File", rawData)


MessageBox.Show("File Inserted into database successfully!", _
"Success!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)

Catch ex As Exception
MessageBox.Show("There was an error: " & ex.Message, "Error", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

Options: ReplyQuote

Written By
Re: Storing/Retrieving BLOB Data directly into a PictureBox in VB.NET
January 31, 2007 04:08PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.