Home | About us | Overview | Softwares - Downloads | Evaluate | Order | Support | old forums | Contact | F.A.Q. | Documentations | Search | Sitemap

How to save images in Access DB

Example requests & Code samples for GdPicture ActiveX.

How to save images in Access DB

Postby MCHSRAS on Tue May 13, 2008 9:32 pm

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?
MCHSRAS
 
Posts: 6
Joined: Thu Apr 24, 2008 3:16 pm

Re: How to save images in Access DB

Postby Loïc on Thu May 15, 2008 3:28 pm

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:

Code: Select all
Private Sub Form_Load()
   Me.RecordSource = "SELECT * FROM table1"
End Sub


3 - Code to append the native image of an Imaging object to the OLE field:

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


Best regards,

Loïc Carrère
User avatar
Loïc
Site Admin
 
Posts: 1195
Joined: Tue Oct 17, 2006 11:48 pm
Location: France


Return to Example requests & Code samples

Who is online

Users browsing this forum: No registered users and 0 guests

cron