Hi maybe this piece of code can help you
Dim ms As New System.IO.Memor yStream()
Dim arrImage() As Byte
PictureBox1.Ima ge.Save(ms, PictureBox1.Ima ge.RawFormat.Jp eg)
arrImage = ms.GetBuffer()
ms.Close()
Dim updCommand As SqlCommand
Try
updCommand = New SqlCommand("Upd ate table set bitmap= @bitmap where
code=@code)
updCommand.Para meters.Add(New SqlParameter("@ bitmap", SqlDbType.Image ))
updCommand.Para meters.Add(New SqlParameter("@ code", SqlDbType.Char) )
updCommand.Para meters("@code") .Value = 'Your code field
if arrImage Is Nothing Then
updCommand.Para meters("@bitmap ").Value = DBNull.Value
Else
updCommand.Para meters("@bitmap ").Value = arrImage
End If
updCommand.Conn ection = 'Your connection
updCommand.Conn ection.Open()
updCommand.Exec uteNonQuery()
updCommand.Conn ection.Close()
Catch ex As Exception
MsgBox(ex.tostr ing)
end try
"Dav" <an*******@disc ussions.microso ft.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(file name, _
FileMode.OpenOr Create, FileAccess.Read )
Dim rawData() As Byte = New Byte(fs.Length) {}
fs.Read(rawData , 0, System.Convert. ToInt32
(fs.Length))
fs.Close()
OleDbDataAdapte r1.InsertComman d.CommandText = _
"Insert Into ImageTest Values (" & rawData & ")"
OleDbDataAdapte r1.InsertComman d.ExecuteNonQue ry()
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