Subject Re: Coping a Binary File
From Forrest Ganther <forrestganther@yahoo.com>
Date Tue, 27 Sep 2016 21:19:16 -0400
Newsgroups dbase.getting-started

Mervyn Bick Wrote:

> On 27-Sep-16 8:50 PM, Forrest wrote:
> > Forrest Wrote:
> >
> >> I am trying to copy a binary file (jpeg/bmp) (that meets criteria) from one table to another table.  I just can't figure it out.  Would someone help me?
> >> Thanks, I would appreciate your help!
> >> Forrest
> > this is one of the things I have tried
> >
> >       dp = new query()
> >       dp.database := d
> >       dp.sql := [SELECT * from Deacons where name = Lnme ]
> >       dp.active   := True
> >
> >       dp.rowset.Fields["Pict"].copyToFile("temp.jpg")
> >       dp.active := false
> >
>
>
> Can you open temp.jpg and view it?  If so, you're half way there.  All
> you need now an a query to write the .jpg into the target table.
>
>
>        dt = new query()
>        dt.database := d
>        dt.sql := [SELECT * from Deacons where name = Lnme ]
>        dt.active   := True
>        dt.beginEdit()
>        dt.rowset.fields["pict"].replaceFromFile('temp.jpg')
>        dt.rowset.save()
>        dt.active := false
>
>
> There' a lot to be said for NOT using a binary field to hold images.
> Instead, keep all the images together in a folder and store the path and
> file name in a character field.
>
> Mervyn.
>
> OK, thanks a bunch Mervyn, really appreciate your help.