?
Solved

store picture in ole (blob) data type filed in msaccess

Posted on 2003-03-04
4
Medium Priority
?
286 Views
Last Modified: 2011-10-03
Hi,
i want to store a picture file (.jpg) in msacess databse.
how to do it with adodc or adodb.recordet.

in msacess i've taken a field as a ole object.

on form i have a picturebox.
i can open a file in picture box. how to store it in database.

Why ole field ?

because i want to drag this picture in crystal report.
there again i can show only .BMP files and no .jpg

thanx
sharad
0
Comment
Question by:sharad2
[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
4 Comments
 
LVL 1

Accepted Solution

by:
BWarmuskerken earned 800 total points
ID: 8064248
Try this...

Sub cmdSave_Click()
    adoRS.AddNew
    SaveBinaryFile "C:\YourPicture.jpg" , adoRS.Fields("Picture")
    adoRS.Update
End Sub



Sub SaveBinaryFile(sFileName, Field As ADODB.Field)
    Dim lFileLength As Long
    Dim lBlocks As Long
    Dim lRemainder As Long
    Dim lCurrBlock As Long
    Dim aData() As Byte
    Dim FileNumber As Long
    Dim mvarBlockSize As Long
   
    FileNumber = FreeFile
    Open sFileName For Binary As #FileNumber
    lFileLength = LOF(FileNumber)
    mvarBlockSize = 1000
           
    'check that \we have somthing in the file
    If lFileLength > 0 Then
        'start the chunk culculations
        lBlocks = Int(lFileLength / mvarBlockSize)
        lRemainder = lFileLength Mod mvarBlockSize
                 
        'add the first chunk
        If lRemainder > 0 Then
            ReDim aData(lRemainder - 1)
            Get #FileNumber, , aData()
            '.Fields("IDropFiles").AppendChunk aData()
            Field.AppendChunk aData()
        End If
                   
        'add the remaining chunks
        For lCurrBlock = 1 To lBlocks
            ReDim aData(mvarBlockSize - 1)
            Get #FileNumber, , aData()
            Field.AppendChunk aData()
        Next lCurrBlock
        Close FileNumber
    End If
End Sub
0
 

Expert Comment

by:CleanupPing
ID: 8900765
sharad2:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9024171
Moderator, my recommended disposition is:

    Accept BWarmuskerken's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
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 In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…
Suggested Courses
Course of the Month10 days, 4 hours left to enroll

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