ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / How to proceed? / Programming
  • Saving an image (or another type of document) in a memo item
  • Retrieving an image (or another type of document) from a Memo item
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
How to save and retrieve an image in a binary memo
ODBCNot available with this kind of connection
The images (or any other type of file) can be stored in a database via memo items. To read or write in a memo item of a data file, you must use:
Saving an image (or another type of document) in a memo item
HLinkMemo is used to save an image or any file in a Memo item of the database. The full syntax of this function is presented in the help page about HLinkMemo.
For example:
  • Saving the photo of a product:
    HReadSeek(Product, ProductRef, "Prd001")
    IF HFound()
    HLinkMemo(Product, ItmPHOTO, "C:\PHOTOS\MyImage.JPG", hMemoImg)
    HModify(Product)
    END
  • Saving a PDF document in a file:
    HReadSeek(Documents, DocID, "Doc3241")
    IF HFound()
    HLinkMemo(Documents, DocumentContent, "C:\My documents\Customer invoice 152.PDF", hMemoBin)
    Documents.DocName = "Customer invoice 152.PDF"
    Documents.DocType = "PDF"
    Documents.BackupDate = Today()
    HModify(Documents)
    END
Retrieving an image (or another type of document) from a Memo item
HExtractMemo is used to retrieve an image or any file found in a Memo item of the database. The full syntax of this function is presented in the help page about HExtractMemo.
For example:
  • Retrieving the photo of a product:
    HReadSeek(Product, ProductRef, "Prd001")
    IF HFound()
    // Extracts the document on disk
    // ItmPHOTO is a memo item of Product file
    HExtractMemo(Product, ItmPHOTO, "C:\PHOTOS\MyImage.JPG")
     
    // Display the image
    MyImageControl = "C:\PHOTOS\MyImage.JPG"
    END
  • Retrieving a PDF document:
    sDocName is string
     
    HReadSeek(Documents, DocID, "Doc3241")
    IF HFound()
    sDocName = fCurrentDir() + ["\"] + Documents.DocName
    // Let's suppose that the source name of the document was saved in the database
     
    // Extract the document on disk
    // DocumentContent is a memo item of Documents file
    HExtractMemo(Documents, DocumentContent, sDocName)
     
    // Display the document
    ShellExecute(sDocName)
    END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 07/05/2022

Send a report | Local help