Search code examples
vb6foxpro

How to insert and retrieve image in dbf file from vb6


I am writing a code in VB6 to save and retrieve an image in .dbf file, but i don't know what field type to take in dbf file. Can anyone suggest what field should i take in dbf file and what code should i write in VB6 ?? Thanks in advance..


Solution

  • I have done it in Memo Fields long ago. The code is in foxpro. See:

    CREATE TABLE Abc.dbf Free (Filename c(50), Store M(4)) &&Create a table with FileName character field
    

    *And Store as memo field

    1.

    Append blank &&to add a blank record
    APPEND MEMO store from "D:\Shah.Jpg" overwrite 
    *This will copy the contents of the file. If Overwrite is ignored, and the memo has some contents,
    *The contents of the file will be appended to it, which should be avoided.
    REPLACE filename WITH "Shah.Jpg"
    *Add as many files as you wish to other records.
    Copy memo Store to "SomePhoto.jpg" && will copy to the default folder
    *Or 
    Copy memo store to "c:\MyPhotos\Shah.JPG" &&You must save or know the extension of the file
    

    2.

    append blank
    filedata=FILETOSTR("D:\Shah.JPG")
    REPLACE store WITH filedata
    STRTOFILE(store,"SomeFileName.JPG")
    *OR
    STRTOFILE(store,"c:\MyPhotos\SomeFileName.JPG")
    

    It should solve your problem.