Solved

Retreiving pictures using SELECT statement

Posted on 1998-09-07
2
147 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
ID: 1433492
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
ID: 1433493
Thanks for the answer,
so now how can i Insert picture to the same database using
INSERT INTO statement

pat_ron
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA : retain and exclude values based on a config sheet and multiple parameters 5 62
Adding to a VBA? 6 77
VB6 ListBox Question 4 48
Problem to line 23 53
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

856 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