Solved

Retreiving pictures using SELECT statement

Posted on 1998-09-07
2
141 Views
Last Modified: 2010-04-30
Gretings,
 How can i retreive pictures from my access database
(Table Name:Plane ,Column Name: pl_planepic) using
SELECT Statement(SQL). Pls. help me .

pat_ron.
0
Comment
Question by:pat_ron
2 Comments
 
LVL 14

Accepted Solution

by:
waty earned 30 total points
Comment Utility
You have to use the following function to save the picture from the DB to a file, and show the file in a picture box.

dim record as RecordSet
dim sSQL   as String

sSQL = "Select pl_planepic from Plane"
set record = DB.OpenRecordset(sSQL, dbOpenDynaset)

.
call GetFileFromDB(record("pl_planepic"), "c:\temp\pict.bmp")



Sub GetFileFromDB(BinaryField As Field, szFileName As String)
    ' *** Will retrieve an entire Binary field and write it to disk ***
   
    Dim NumBlocks    As Long
    Dim TotalSize    As Long
    Dim RemBlocks    As Integer
    Dim CurSize      As Integer
    Dim nBlockSize   As Long
    Dim nI           As Integer
    Dim nFile        As Integer
    Dim CurChunk     As String
   
    nBlockSize = 32000    ' Set size of chunk.
   
    ' *** Get field size.
    TotalSize = BinaryField.FieldSize()
    NumBlocks = TotalSize \ nBlockSize   ' Set number of chunks.
   
    ' *** Set number of remaining bytes.
    RemBlocks = TotalSize Mod nBlockSize
   
    ' *** Set starting size of chunk.
    CurSize = nBlockSize
    nFile = FreeFile ' Get free file number.
   
    Open szFileName For Binary As #nFile  ' Open the file.
    For nI = 0 To NumBlocks
       If nI = NumBlocks Then CurSize = RemBlocks
       CurChunk = BinaryField.GetChunk(nI * nBlockSize, CurSize)
       Put #nFile, , CurChunk   ' Write chunk to file.
    Next
    Close nFile

End Sub

0
 

Author Comment

by:pat_ron
Comment Utility
Thanks for the answer,
so now how can i Insert picture to the same database using
INSERT INTO statement

pat_ron
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now