PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • 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/iPadApple WatchUniversal Windows 10 AppWindows Mobile
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.
Some examples:
  • 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.
Some examples:
  • 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", hMemoImg)

    // 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, hMemoBin)

    // Display the document
    ShellExecute(sDocName)
    END
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment