I wish to save and retrieve image in access 2007.
in our search module , if employee number typed, it could retrieve all information of the employee including the image saved in database(?) if this can be happen?

Dani AI

Generated

Yes — you can save and retrieve employee photos with Access 2007; there are three practical choices and each has tradeoffs. correctly pointed to the two common paths (external file path vs storing the bytes). Access 2007 also introduced the Attachment data type (best native option for accdb files): it stores files in their native formats, allows multiple files per record, and manages compression and rendering for images. (support.microsoft.com)

If you want the image inside the database so the app can pull everything by employee number, use either:

  • the Attachment field (create an Attachment column in your table and add files via the Attachments dialog or programmatically with DAO Recordset2.LoadFromFile / SaveToFile), or
  • a binary column (OLE Object / long binary) and write/read raw bytes from VB.NET with parameterized OleDb commands and a MemoryStream. For programmatic attachments use DAO; for a simple BLOB workflow use ADO.NET (MemoryStream -> byte[]) and OleDbParameter of type Binary. (learn.microsoft.com)

Short VB.NET pattern (concept only — adjust names/connection string):

' Save: convert PictureBox image to byte() and pass as parameter (OleDbType.Binary).
' Retrieve: SELECT Photo FROM Employees WHERE EmpID = ?; get byte(), use MemoryStream, then Image.FromStream(ms).

A few practical rules: prefer storing file paths (and keeping images on a file server or cloud) when you have many or large images — Access has a ~2GB file size limit and DB bloat / slow backups are common when images are embedded. If you embed images, use parameters (never concatenate user input) and be ready for bitness/provider issues when connecting to .accdb (use the ACE OLEDB provider and match 32/64-bit). Also be aware that legacy OLE Object storage can wrap images with OLE headers and not behave well in reports; Attachment fields avoid that. (support.microsoft.com)

Actionable next steps: decide whether you need single-file deployment (embed) or lighter DB (paths). If embedding, add an Attachment field in the table and use DAO/VBA or ADO.NET with OleDb binary parameters to save/retrieve; if using paths, store a relative path and ensure your deployment keeps the image files alongside the app.

Recommended Answers

All 5 Replies

There are two ways of doing this.

You can save a path to the image

OR

You can save the image into the database (As a blob)

You can save the image into the database (As a blob)

how to do that? can you give me a code about that? i'm such a beginner in this matter. thank you~

Here is Microsoft's Article on how to do so.

i'm using access 2007 . :3

You are not asking for vb.net related material, just Access help?

If so, I can flag your post to get a mod to transfer it to the correct forum.

Or perhaps I am misunderstanding...

From my experience, it's easier to define a field for a string that contains the path to the file.

This will keep the database from having to pour over Blobs to retreive data.

This can be done by simply performing an insert.

"INSERT INTO table(column1,column2,column3) VALUES ('name','address','C:/Users/paoi00/myPic.jpg')" 'Of course you will change the path to the true path.

What language library are you using?

Jet, OleDB...?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.