Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

dot net connector + vb.net + picture + blob (no replies)

$
0
0
Good Day

Hope anyone could help me i have a program that should display worker photo's, but could not manage to get it working in mysql (it is working in firebird, but i prefer mysql).

My Vb.net code :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
With OFDialog1
.InitialDirectory = "C:\"
.Filter = "All Files|*.*|Bitmaps|*.bmp|GIFs|*.gif|JPEGs|*.jpg"
.FilterIndex = 2
End With

If OFDialog1.ShowDialog() = DialogResult.OK Then
With PictureBox1
.Image = Image.FromFile(Me.OFDialog1.FileName)
.SizeMode = PictureBoxSizeMode.StretchImage
End With
End If


Dim ms As New MemoryStream
Me.PictureBox1.Image.Save(ms, Me.PictureBox1.Image.RawFormat)

Dim arrayImage() As Byte = ms.GetBuffer
ms.Close() ' Closes the Memory Stream
MsgBox(arrayImage.Length)

SqlCmd1.CommandText = "INSERT INTO mytable (PHOTO) VALUES (?)"
SqlCmd1.Parameters.Add("?Param1", SqlDbType.Image, arrayImage.Length).Value = arrayImage


DB1.Open()
SqlCmd1.ExecuteNonQuery()
DB1.Close()

End Sub

It gives me the following error if executed :
"Fatal error encountered during command execution."


Thank you in advance

Albertus Geyser

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>