Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Retreiving pictures using SELECT statement

Posted on 1998-09-07
2
Medium Priority
?
151 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
waty earned 120 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

604 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