Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread Saving a image in a DBISAM blob field from EWB - nothing saved
Thu, Dec 5 2019 5:02 AMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Hi All,

I have searched the newsgroups and decided to code following to insert a
image in a dbisam table. There is a module part (rapport) and a ewb form
part. EWB form contains a THTMLform (named BilledeForm) with a
filecombobox and a button on it. When user clicks on the button
following happens:

// EWB:

BilledeForm.URL :=
'modules/rapport?'+'upload=billede&'+'firmanr='+inttostr(myDataset.columns['firmanr'].asinteger)+'&login='+myDataset.Columns['Login'].AsString;
BilledeForm.Submit;

This is the server (module part).

// Module code:

else if AnsiSameText(Request.RequestParams.Values['upload'],'billede')
then begin
              with MedarbejderBillede do begin
                    if active then close;
              SQL.Clear;
              SQL.Add('select billede from medarb where firmanr =
:firmanum and upper(login) = :loginnum');
              parambyname('firmanum').AsInteger :=
strtoint(Request.RequestParams.Values['firmanr']);
              parambyname('loginnum').AsString :=
uppercase(Request.RequestParams.Values['login']);
              open;
              end;
              if (Request.RequestMIMEParts.Count = 1) and
(MedarbejderBillede.RecordCount = 1) then
              begin
              MedarbejderBillede.Edit;
              TempBillede:=TMemoryStream.Create;
              try
              Request.RequestMIMEParts[0].Save(TempBillede);
TBlobField(MedarbejderBillede.FieldByName('Billede')).LoadFromStream(TempBillede);
              MedarbejderBillede.Post;
              Request.SendContent('OK');
              finally
              TempBillede.Free;
              end;
              end;
              if (MedarbejderBillede.RecordCount = 0) then
Request.SendContent('Medarbejder ikke fundet!');
              MedarbejderBillede.Close;
end

If i ispect the traffic with fiddler i can see that the server sends
'OK' as message back, but nothing seems to be saved in the table?

What do I miss here?

Thanks in advance.
Regards,
Hüseyin

Mon, Dec 9 2019 9:17 AMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

No one with input to this question? Smile

Den 05-12-2019 kl. 11:02 skrev Hüseyin Aliz:
> Hi All,
>
> I have searched the newsgroups and decided to code following to insert
> a image in a dbisam table. There is a module part (rapport) and a ewb
> form part. EWB form contains a THTMLform (named BilledeForm) with a
> filecombobox and a button on it. When user clicks on the button
> following happens:
>
> // EWB:
>
> BilledeForm.URL :=
> 'modules/rapport?'+'upload=billede&'+'firmanr='+inttostr(myDataset.columns['firmanr'].asinteger)+'&login='+myDataset.Columns['Login'].AsString;
> BilledeForm.Submit;
>
> This is the server (module part).
>
> // Module code:
>
> else if AnsiSameText(Request.RequestParams.Values['upload'],'billede')
> then begin
>               with MedarbejderBillede do begin
>                     if active then close;
>               SQL.Clear;
>               SQL.Add('select billede from medarb where firmanr =
> :firmanum and upper(login) = :loginnum');
>               parambyname('firmanum').AsInteger :=
> strtoint(Request.RequestParams.Values['firmanr']);
>               parambyname('loginnum').AsString :=
> uppercase(Request.RequestParams.Values['login']);
>               open;
>               end;
>               if (Request.RequestMIMEParts.Count = 1) and
> (MedarbejderBillede.RecordCount = 1) then
>               begin
>               MedarbejderBillede.Edit;
>               TempBillede:=TMemoryStream.Create;
>               try
>               Request.RequestMIMEParts[0].Save(TempBillede);
> TBlobField(MedarbejderBillede.FieldByName('Billede')).LoadFromStream(TempBillede);
>
>               MedarbejderBillede.Post;
>               Request.SendContent('OK');
>               finally
>               TempBillede.Free;
>               end;
>               end;
>               if (MedarbejderBillede.RecordCount = 0) then
> Request.SendContent('Medarbejder ikke fundet!');
>               MedarbejderBillede.Close;
> end
>
> If i ispect the traffic with fiddler i can see that the server sends
> 'OK' as message back, but nothing seems to be saved in the table?
>
> What do I miss here?
>
> Thanks in advance.
> Regards,
> Hüseyin
>
>
Mon, Dec 9 2019 10:48 AMPermanent Link

Raul

Team Elevate Team Elevate

On 12/9/2019 9:17 AM, Hüseyin Aliz wrote:
> No one with input to this question? Smile
>

First thought i have is to confirm your MedarbejderBillede is actually a
live resultset (i.e. check ResultIsLive property after opening).


Raul
Mon, Dec 9 2019 1:26 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Huseyin,

<< If i ispect the traffic with fiddler i can see that the server sends  'OK' as message back, but nothing seems to be saved in the table? >>

In addition to what Raul said, you can use the Delphi debugger to step through the module and make sure that a) you're actually executing the module that you think you're executing, and b) that the result is live, etc.

Open your module project in the Delphi IDE, make sure that the EWB IDE is set as the host application under the Run/Parameters option in the Delphi IDE, and then run the application.  You should see the EWB IDE start up, and then you can just run the EWB application to test things out.  This all assumes that you have already added the compiled module to the installed internal web server modules using the Environment Options dialog in the EWB IDE.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Dec 9 2019 4:33 PMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Hi Raul,

Thanks for input. MedarbejderBillede has the ResultIsLive property set
to true. By using a tbrowser (thtmlform output), i have also checked
that sql.text with parameters are as expected. It's weird.

Regards,
Hüseyin

Den 09-12-2019 kl. 16:48 skrev Raul:
> On 12/9/2019 9:17 AM, Hüseyin Aliz wrote:
>> No one with input to this question? Smile
>>
>
> First thought i have is to confirm your MedarbejderBillede is actually
> a live resultset (i.e. check ResultIsLive property after opening).
>
>
> Raul
Mon, Dec 9 2019 4:54 PMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Tim,

Checked both a and b, no issue here as i can see, custom request message
are sent and received, so its the correct module loaded, and in module
dataset/query resultislive property are set, and dataset.sql.text seems
to be the same as expected.

Can it be a issue/bug with ewb module and blob handling?

Regards,
Hüseyin

Den 09-12-2019 kl. 19:26 skrev Tim Young [Elevate Software]:
> Huseyin,
>
> << If i ispect the traffic with fiddler i can see that the server sends  'OK' as message back, but nothing seems to be saved in the table? >>
>
> In addition to what Raul said, you can use the Delphi debugger to step through the module and make sure that a) you're actually executing the module that you think you're executing, and b) that the result is live, etc.
>
> Open your module project in the Delphi IDE, make sure that the EWB IDE is set as the host application under the Run/Parameters option in the Delphi IDE, and then run the application.  You should see the EWB IDE start up, and then you can just run the EWB application to test things out.  This all assumes that you have already added the compiled module to the installed internal web server modules using the Environment Options dialog in the EWB IDE.
>
> Tim Young
> Elevate Software
> www.elevatesoft.com
>
Tue, Dec 10 2019 12:23 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Huseyin,

<< Checked both a and b, no issue here as i can see, custom request message are sent and received, so its the correct module loaded, and in module dataset/query resultislive property are set, and dataset.sql.text seems
to be the same as expected.

Can it be a issue/bug with ewb module and blob handling? >>

EWB isn't really concerned with BLOBs, other than with respect to the multi-part MIME handling.

Did you verify that the multi-part MIME content isn't empty and has actual data in it ?

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Dec 11 2019 9:11 AMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Tim,

Now i am more confused than before Smile

For a test i've put a dbisamtable pointing to the same table as the
query, and instead of editing the record found (have another strange
issue with this - but will ask later), i just append to the table, with
primary key, another field + blob field, this will not save either. I
would expect that even though blob has a issue or is empty, it would
save the record.

This code used for test:

      TempBillede:=TMemoryStream.Create;
              try
              TempBillede.Position := 0;
              Request.RequestMIMEParts[0].Save(TempBillede);
              with Medarbejdere do begin    //Medarbejdere is a
DBISAMtable connected to same session as rest
              if not active then open;
              append;
              Medarbejdere.FieldByName('Firmanr').AsInteger := 1;
              Medarbejdere.FieldByName('Login').AsString := '5';  //
This is the primary key of the table
TBlobField(Medarbejdere.FieldByName('Billede')).LoadFromStream(TempBillede);
              Medarbejdere.Post;
              end;
              Request.SendContent('OK');
              finally
              TempBillede.Free;
              end;

Regards,
Huseyin

Den 10-12-2019 kl. 18:23 skrev Tim Young [Elevate Software]:
> Huseyin,
>
> << Checked both a and b, no issue here as i can see, custom request message are sent and received, so its the correct module loaded, and in module dataset/query resultislive property are set, and dataset.sql.text seems
> to be the same as expected.
>
> Can it be a issue/bug with ewb module and blob handling? >>
>
> EWB isn't really concerned with BLOBs, other than with respect to the multi-part MIME handling.
>
> Did you verify that the multi-part MIME content isn't empty and has actual data in it ?
>
> Tim Young
> Elevate Software
> www.elevatesoft.com
>
Mon, Dec 16 2019 7:40 AMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Hi All,

Another issue (probably not directly related to original issue)
regarding parameters and uppercase when value contains numbers..

Following SQL runs fine from DBsys:

select login,billede from medarb where firmanr = 1 and upper(login) = '3'

// returns 1 rows

Same SQL running from a EWB module (DBISAM latest), returns 0 rows.

This one are ok from both:

select login,billede from medarb where firmanr = 1 and upper(login) = 'DEMO'

so i think it has something to do with numbers not compared with
uppercase, or maybe i do something wrong Smile

This is how parameters are sent from EWB to the module:

with FjernBillede do
   begin
      Method := rmPost;
      URL := 'modules/rapport';
      Params.Clear;
      Params.Values['fjern']:='billede';
Params.Values['firmanr']:=inttostr(myDataset.columns['firmanr'].asinteger);
Params.Values['login']:=uppercase(QuotedStr(myDataset.Columns['Login'].AsString));
      Execute;
end;

Anyone have an idea?

Regards,
Huseyin

Den 11-12-2019 kl. 15:11 skrev Hüseyin Aliz:
> Tim,
>
> Now i am more confused than before Smile
>
> For a test i've put a dbisamtable pointing to the same table as the
> query, and instead of editing the record found (have another strange
> issue with this - but will ask later), i just append to the table,
> with primary key, another field + blob field, this will not save
> either. I would expect that even though blob has a issue or is empty,
> it would save the record.
>
> This code used for test:
>
>       TempBillede:=TMemoryStream.Create;
>               try
>               TempBillede.Position := 0;
>               Request.RequestMIMEParts[0].Save(TempBillede);
>               with Medarbejdere do begin    //Medarbejdere is a
> DBISAMtable connected to same session as rest
>               if not active then open;
>               append;
>               Medarbejdere.FieldByName('Firmanr').AsInteger := 1;
>               Medarbejdere.FieldByName('Login').AsString := '5'; //
> This is the primary key of the table
> TBlobField(Medarbejdere.FieldByName('Billede')).LoadFromStream(TempBillede);
>
>               Medarbejdere.Post;
>               end;
>               Request.SendContent('OK');
>               finally
>               TempBillede.Free;
>               end;
>
> Regards,
> Huseyin
>
> Den 10-12-2019 kl. 18:23 skrev Tim Young [Elevate Software]:
>> Huseyin,
>>
>> << Checked both a and b, no issue here as i can see, custom request
>> message are sent and received, so its the correct module loaded, and
>> in module dataset/query resultislive property are set, and
>> dataset.sql.text seems
>> to be the same as expected.
>>
>> Can it be a issue/bug with ewb module and blob handling? >>
>>
>> EWB isn't really concerned with BLOBs, other than with respect to the
>> multi-part MIME handling.
>>
>> Did you verify that the multi-part MIME content isn't empty and has
>> actual data in it ?
>>
>> Tim Young
>> Elevate Software
>> www.elevatesoft.com
>>
>
Mon, Dec 16 2019 7:43 AMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Forgot the ewb module code:

          else if
AnsiSameText(Request.RequestParams.Values['fjern'],'billede') then
              begin
              with MedarbejderBillede do begin
                    if active then close;
              Requestlive := true;
              SQL.Clear;
              SQL.Add('select login,billede from medarb where firmanr =
:firmanum and upper(login) = :loginnum');
              MedarbejderBillede.SQL.Text :=
StringReplace(MedarbejderBillede.SQL.Text,':firmanum',Request.RequestParams.Values['firmanr'],[rfReplaceAll]);
              MedarbejderBillede.SQL.Text :=
StringReplace(MedarbejderBillede.SQL.Text,':loginnum',Request.RequestParams.Values['login'],[rfReplaceAll]);
              open;
              end;
              if (MedarbejderBillede.FieldByName('login').AsString <>
'') then
              begin
              MedarbejderBillede.Edit;
              MedarbejderBillede.FieldByName('Billede').clear;
              MedarbejderBillede.Post;
              Request.SendContent('Billedet er fjernet');
              end;
              if (MedarbejderBillede.RecordCount = 0) then
Request.SendContent(MedarbejderBillede.SQL.Text);
              MedarbejderBillede.Close;
              end

Den 16-12-2019 kl. 13:40 skrev Hüseyin Aliz:
> Hi All,
>
> Another issue (probably not directly related to original issue)
> regarding parameters and uppercase when value contains numbers..
>
> Following SQL runs fine from DBsys:
>
> select login,billede from medarb where firmanr = 1 and upper(login) = '3'
>
> // returns 1 rows
>
> Same SQL running from a EWB module (DBISAM latest), returns 0 rows.
>
> This one are ok from both:
>
> select login,billede from medarb where firmanr = 1 and upper(login) =
> 'DEMO'
>
> so i think it has something to do with numbers not compared with
> uppercase, or maybe i do something wrong Smile
>
> This is how parameters are sent from EWB to the module:
>
> with FjernBillede do
>    begin
>       Method := rmPost;
>       URL := 'modules/rapport';
>       Params.Clear;
>       Params.Values['fjern']:='billede';
> Params.Values['firmanr']:=inttostr(myDataset.columns['firmanr'].asinteger);
>
> Params.Values['login']:=uppercase(QuotedStr(myDataset.Columns['Login'].AsString));
>
>       Execute;
> end;
>
> Anyone have an idea?
>
> Regards,
> Huseyin
>
Image