How to save images in Access DB
How to save images in Access DB
In the samples, there isn't any code on how to save an image in an Access db. Is there a way to save the image in an AccessDB?
Re: How to save images in Access DB
Hi,
You can download the last package of GdPicture Pro. It include an Access sample which shows how to load / save an image using an OLE field.
1 - Create a table (table1) with 3 fields:
ID: numeric (primary key)
Title: String (50)
Image: OLE
2 - into a form add:
3 - Code to append the native image of an Imaging object to the OLE field:
4 - Code to read an image from the OLE field:
Best regards,
Loïc Carrère
You can download the last package of GdPicture Pro. It include an Access sample which shows how to load / save an image using an OLE field.
1 - Create a table (table1) with 3 fields:
ID: numeric (primary key)
Title: String (50)
Image: OLE
2 - into a form add:
Code: Select all
Private Sub Form_Load()
Me.RecordSource = "SELECT * FROM table1"
End Sub
Code: Select all
Dim arBytes() As Byte
If Imaging1.SaveAsByteArray(arBytes, 0, "jpg") = 0 Then
Me.Recordset.Edit
Me.Recordset.Fields("Image").AppendChunk arBytes
Me.Recordset.Update
MsgBox "Image saved"
End If
Erase arBytes
4 - Code to read an image from the OLE field:
Code: Select all
Dim arbyte() As Byte
arbyte = Me.Recordset.Fields("Image").GetChunk(0, LenB(Me.Recordset.Fields("Image")))
Call Imaging1.CreateImageFromByteArray(arbyte)
Erase arbyte
Loïc Carrère
Who is online
Users browsing this forum: No registered users and 2 guests