Hi maybe this piece of code can help you
Dim ms As New System.IO.MemoryStream()
Dim arrImage() As Byte
PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat.Jpeg)
arrImage = ms.GetBuffer()
ms.Close()
Dim updCommand As SqlCommand
Try
updCommand = New SqlCommand("Update table set bitmap= @bitmap where
code=@code)
updCommand.Parameters.Add(New SqlParameter("@bitmap", SqlDbType.Image))
updCommand.Parameters.Add(New SqlParameter("@code", SqlDbType.Char))
updCommand.Parameters("@code").Value = 'Your code field
if arrImage Is Nothing Then
updCommand.Parameters("@bitmap").Value = DBNull.Value
Else
updCommand.Parameters("@bitmap").Value = arrImage
End If
updCommand.Connection = 'Your connection
updCommand.Connection.Open()
updCommand.ExecuteNonQuery()
updCommand.Connection.Close()
Catch ex As Exception
MsgBox(ex.tostring)
end try
"Dav" <an*******@discussions.microsoft.com> wrote in message
news:0d****************************@phx.gbl...
Hi all,
I am using these code to save Image to database:
Dim fs As FileStream = New FileStream(filename, _
FileMode.OpenOrCreate, FileAccess.Read)
Dim rawData() As Byte = New Byte(fs.Length) {}
fs.Read(rawData, 0, System.Convert.ToInt32
(fs.Length))
fs.Close()
OleDbDataAdapter1.InsertCommand.CommandText = _
"Insert Into ImageTest Values (" & rawData & ")"
OleDbDataAdapter1.InsertCommand.ExecuteNonQuery()
MsgBox("Image saved to database")
But there is a problem in :
"Insert Into ImageTest Values (" & rawData & ")"
The error message is
Operator '&' is not defined for types 'String' and '1-
dimensional array of Byte'.
Anyone can help
Thanks