you can convert an image to a stream then store it to an access database Dim ms As New MemoryStream PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat) Dim imageX() As Byte = ms.GetBuffer ms.Close()
After this step you already have an image in bytes() - imageX Now.. assuming you have an access database with three fields. Message, Name, and PiC (pic is an OLE Object in access) You need to use an OledbCommand's Parameter to pass the values correctyl. here's How to Do it. oledbcommand1.Parameters.Clear() oledbcommand1.Parameters.Add(New OleDbParameter("@MESSAGE", OleDbType.WChar, 50)).Value = TextBox1.Text oledbcommand1.Parameters.Add(New OleDbParameter("@NAME", OleDbType.WChar, 50)).Value = TextBox2.Text oledbcommand1.Parameters.Add(New OleDbParameter("@PIC", OleDbType.Binary)).Value = image If VEN.Insert("INSERT INTO Table1 ( MESSAGE , NAME1 , PIC ) VALUES ( ? , ? , ? )") = 1 Then MessageBox.Show("Record Save!") Me.Close() End If
ofcourse you need to setup a connection to an access database. only images added trhough this method can be retireived. to retrieve the image you need to reverse the step Dim i As Integer If IsDBNull(TABLE.Rows(ROW)(iFIELD)) Then MsgBox("You Tried to View an Image from an empty record", MsgBoxStyle.OKOnly, "Unable to Display Image") Exit Sub End If Dim arrPicture() As Byte = CType(TABLE.Rows(ROW)("PIC"),byte()) Dim ms As New MemoryStream(arrPicture) picturebox1.image = System.Drawing.Image.FromStream(ms)
GUERVEN Truth or Consequence