Photo handling

Hi,
I’m using DB to keep the sketch photo. Because it needs to show in Crystal Report and export to Excel by TMS FlexCel component. I want to using file base. Is DA handle that?

Hi,

what do you mean under file base ?

Hi,
That means the table keep the file path only and photo files are keeping in file server.

Hi,

you can keep file path in the DB and send image to client by request (via custom method) or read image and put it to dataset in the Bin2.OnWriteFieldValueEx event on server-side.

in second way, you should declare field as ServerCalculated or include it to SQL like

NULL as "PhotoField"

and set BLOB type for this field.

in the OnWriteFieldValueEx event, you should read image from disk and fill correspondent field.

Hi,
Thanks. I will try it. Any demo for my reference. :sweat_smile:

Hi,

check this sample:
VCLApplication.zip (61.5 KB)

Hi,
Thanks for your example. I tested and have the basic concept about this. But if table has more than 1 photo field, then I need to pass the fieldslist in DataStreamerWriteFieldValueEx. Right?

Hi,

in this event you can check for all photo fields:

    if aField.Name = 'Photo' then begin
       ...
    end
..
    else  if aField.Name = 'Photo9' then begin
       ...
    end;

Hi,
Haha… Yes. I forgot to use this solution. Because I focus on multiple fields that like DataParameterArray.

Thanks again.

Hi,
I tried to apply your sample to my project. It works fine. But it has an error when apply to TMS FlexCel. The error is as below. This error is not happen for all records. It just happened in some specific records. If I removed new photo field, it works fine without error. I asked TMS support who replied their product can handle all unicode. I passed your DataStreamerWriteFieldValuesEx for them and they guess the problem is “Values : Variant”.

unicode

Hi,

Looks like extra UTF8->Unicode conversion is called.
How is your field is declared in Schema Modeler? datBlob & dabtGraphic ?

Hi,
I declare to datBlob in Schema Modeler. Some records are normal. Some records will return the error when using TMS FlexCel.

Hi,

Does TMS FlexCel accept TBytes/TStream as input data?

Hi,
My existing project is using “varbinary” in SQL server and save the photo in table record directly. Now I’m using your solution that skip my existing method. Because I need to sync the files to DB by sperate program and run it daily.

TMS FlexCel only need to have dataset result. Then the dataset will pass to Excel directly. They said their product has a very complete unicode suppor and it is tested heavily. They advise the problem may come from “Variant” type in the value.

Hi,

try to connect TMS FlexCel to your DB directly w/o DAD components. will TMS FlexCel display “broken records” correctly ?

Hi,
This error will not broken the records. I checked it before. It will not show the photo only after I click “Continue”.

Hi,

When you don’t use DAD, TMS FlexCel shows all records correctly that weren’t shown with DAD?

Hi,
What is the meaning of DAD? Is DADataSource? If yes, then TMS FlexCel only support by dataset.

DAD = Data Abstract for Delphi.

Hi,
In my existing project, I’m using SDAC and Delphi XE2 without error. TMS replied me XE2 will replace the invalid unicode character by a “?”. But newer Delphi will raise an exception.