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
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