Re: Storing/Retrieving BLOB Data directly into a PictureBox in VB.NET
Posted by: Sourjya Sen
Date: November 18, 2004 10:41AM

But that's what I did --> here's a line to line comparision for better readability...

My Code
=====================================::::====================

1. Dim ms As MemoryStream = New MemoryStream
2. picShowPicture.Image.Save(ms, ImageFormat.Jpeg)
3. Dim bytBLOBData(ms.Length - 1) As Byte
4. ms.Position = 0
5. ms.Read(bytBLOBData, 0, ms.Length)

6. Dim prm As New MySql.Data.MySqlClient.MySqlParameter("@BLOBData", _
MySql.Data.MySqlClient.MySqlDbType.Blob, _
bytBLOBData.Length, ParameterDirection.Input, False, _
0, 0, Nothing, DataRowVersion.Current, bytBLOBData)


7. Dim ConnectionString As String = "SERVER=localhost;" & _
"PORT=3306;DATABASE=pictureDB;User Id=root;" & _
"PASSWORD=pass;"

8. Dim QueryString As String = "INSERT INTO blobtest ( BLOBData ) VALUES ( @BLOBData )"
Dim myConnection As New MySqlConnection(ConnectionString)
Dim myCommand As New MySqlCommand(QueryString)
myCommand.Connection = myConnection

9. myCommand.Parameters.Add(prm)

10. myConnection.Open()
11. myCommand.ExecuteNonQuery()
12. myConnection.Close()

End Sub
======== End of my Code

In Comparision - here's the Microsoft Code:
==============================
1. Dim ms As MemoryStream = New MemoryStream()
2. picBLOB.Image.Save(ms, ImageFormat.Jpeg)
3. Dim bytBLOBData(ms.Length - 1) As Byte
4. ms.Position = 0
5. ms.Read(bytBLOBData, 0, ms.Length)

6. Dim prm As New SqlParameter("@BLOBData", SqlDbType.VarBinary, _
bytBLOBData.Length, ParameterDirection.Input, False, _
0, 0, Nothing, DataRowVersion.Current, bytBLOBData)

7. Dim cn As New SqlConnection(strCn)
8. Dim cmd As New SqlCommand("INSERT INTO BLOBTest (BLOBData) " & _
"VALUES (@BLOBData)", cn)


9. cmd.Parameters.Add(prm)

10. cn.Open()
11. cmd.ExecuteNonQuery()
12. cn.Close()
==============================


If you compare using the line numbers you'll see that the syntax might be a little different but they essentially do the same stuff - that still leaves me in a tight spot as to why the picture won't get inserted. If the microsoft routine works- why not the one thro' the MySQL.NET connector. Anyone please with a full working example code....
Thanks for your response...

Options: ReplyQuote


Subject
Written By
Posted
Re: Storing/Retrieving BLOB Data directly into a PictureBox in VB.NET
November 18, 2004 10:41AM


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.