# Photo handling

**URL:** https://talk.remobjects.com/t/photo-handling/25200
**Category:** Data Abstract
**Tags:** delphi
**Created:** [August 11, 2021, 7:38am UTC](https://talk.remobjects.com/t/photo-handling/25200 "2021-08-11T07:38:57Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![TIMOTHY\_LAM](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/76d3ee/32.png) [@TIMOTHY\_LAM](https://talk.remobjects.com/u/TIMOTHY_LAM)
#### Post date: [August 11, 2021, 7:38am UTC](https://talk.remobjects.com/t/photo-handling/25200/1 "2021-08-11T07:38:57Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [August 11, 2021, 7:48am UTC](https://talk.remobjects.com/t/photo-handling/25200/2 "2021-08-11T07:48:13Z")

</div>

Hi,

what do you mean under `file base` ?

---

<div class="post-metadata">

### Author: ![TIMOTHY\_LAM](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/76d3ee/32.png) [@TIMOTHY\_LAM](https://talk.remobjects.com/u/TIMOTHY_LAM)
#### Post date: [August 11, 2021, 7:52am UTC](https://talk.remobjects.com/t/photo-handling/25200/3 "2021-08-11T07:52:34Z")

</div>

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

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [August 11, 2021, 8:12am UTC](https://talk.remobjects.com/t/photo-handling/25200/4 "2021-08-11T08:12:33Z")

</div>

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

```sql
NULL as "PhotoField"

```

and set `BLOB` type for this field.

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

---

<div class="post-metadata">

### Author: ![TIMOTHY\_LAM](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/76d3ee/32.png) [@TIMOTHY\_LAM](https://talk.remobjects.com/u/TIMOTHY_LAM)
#### Post date: [August 11, 2021, 8:27am UTC](https://talk.remobjects.com/t/photo-handling/25200/5 "2021-08-11T08:27:07Z")

</div>

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

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [August 11, 2021, 9:18am UTC](https://talk.remobjects.com/t/photo-handling/25200/6 "2021-08-11T09:18:49Z")

</div>

Hi,

check this sample:  
[VCLApplication.zip](https://talk.remobjects.com/uploads/short-url/brZzL5dffDpbPNV7pZ0q8Pk3XDP.zip) (61.5 KB)

---

<div class="post-metadata">

### Author: ![TIMOTHY\_LAM](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/76d3ee/32.png) [@TIMOTHY\_LAM](https://talk.remobjects.com/u/TIMOTHY_LAM)
#### Post date: [August 11, 2021, 9:28am UTC](https://talk.remobjects.com/t/photo-handling/25200/7 "2021-08-11T09:28:19Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [August 11, 2021, 9:30am UTC](https://talk.remobjects.com/t/photo-handling/25200/8 "2021-08-11T09:30:32Z")

</div>

Hi,

in this event you can check for all photo fields:

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

```

---

<div class="post-metadata">

### Author: ![TIMOTHY\_LAM](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/76d3ee/32.png) [@TIMOTHY\_LAM](https://talk.remobjects.com/u/TIMOTHY_LAM)
#### Post date: [August 11, 2021, 9:34am UTC](https://talk.remobjects.com/t/photo-handling/25200/9 "2021-08-11T09:34:07Z")

</div>

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

Thanks again.

---

<div class="post-metadata">

### Author: ![TIMOTHY\_LAM](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/76d3ee/32.png) [@TIMOTHY\_LAM](https://talk.remobjects.com/u/TIMOTHY_LAM)
#### Post date: [February 14, 2022, 2:30am UTC](https://talk.remobjects.com/t/photo-handling/25200/10 "2022-02-14T02:30:28Z")

</div>

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](https://talk.remobjects.com/uploads/default/original/3X/6/4/641aa7acd42d6dc3d64e233f0ddeaaaba9edf90a.jpeg)

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [February 14, 2022, 11:47am UTC](https://talk.remobjects.com/t/photo-handling/25200/11 "2022-02-14T11:47:44Z")

</div>

Hi,

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

---

<div class="post-metadata">

### Author: ![TIMOTHY\_LAM](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/76d3ee/32.png) [@TIMOTHY\_LAM](https://talk.remobjects.com/u/TIMOTHY_LAM)
#### Post date: [February 14, 2022, 12:06pm UTC](https://talk.remobjects.com/t/photo-handling/25200/12 "2022-02-14T12:06:01Z")

</div>

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

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [February 14, 2022, 12:14pm UTC](https://talk.remobjects.com/t/photo-handling/25200/13 "2022-02-14T12:14:47Z")

</div>

Hi,

Does TMS FlexCel accept TBytes/TStream as input data?

---

<div class="post-metadata">

### Author: ![TIMOTHY\_LAM](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/76d3ee/32.png) [@TIMOTHY\_LAM](https://talk.remobjects.com/u/TIMOTHY_LAM)
#### Post date: [February 14, 2022, 12:35pm UTC](https://talk.remobjects.com/t/photo-handling/25200/14 "2022-02-14T12:35:01Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [February 14, 2022, 12:42pm UTC](https://talk.remobjects.com/t/photo-handling/25200/15 "2022-02-14T12:42:38Z")

</div>

Hi,

> [@TIMOTHY\_LAM](#):
>
> Some records will return the error when using TMS FlexCel.

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

---

<div class="post-metadata">

### Author: ![TIMOTHY\_LAM](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/76d3ee/32.png) [@TIMOTHY\_LAM](https://talk.remobjects.com/u/TIMOTHY_LAM)
#### Post date: [February 14, 2022, 12:56pm UTC](https://talk.remobjects.com/t/photo-handling/25200/16 "2022-02-14T12:56:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [February 14, 2022, 1:04pm UTC](https://talk.remobjects.com/t/photo-handling/25200/17 "2022-02-14T13:04:42Z")

</div>

Hi,

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

---

<div class="post-metadata">

### Author: ![TIMOTHY\_LAM](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/76d3ee/32.png) [@TIMOTHY\_LAM](https://talk.remobjects.com/u/TIMOTHY_LAM)
#### Post date: [February 14, 2022, 1:08pm UTC](https://talk.remobjects.com/t/photo-handling/25200/18 "2022-02-14T13:08:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [February 14, 2022, 1:16pm UTC](https://talk.remobjects.com/t/photo-handling/25200/19 "2022-02-14T13:16:21Z")

</div>

DAD = Data Abstract for Delphi.

---

<div class="post-metadata">

### Author: ![TIMOTHY\_LAM](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/76d3ee/32.png) [@TIMOTHY\_LAM](https://talk.remobjects.com/u/TIMOTHY_LAM)
#### Post date: [February 14, 2022, 1:23pm UTC](https://talk.remobjects.com/t/photo-handling/25200/20 "2022-02-14T13:23:18Z")

</div>

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.

[Next page](https://talk.remobjects.com/t/photo-handling/25200.md?page=2)
