简体   繁体   中英

Error loading image from clientdataset using datasnap [Delphi XE7, firemonkey mobile]

I am using Delphi XE7, Firemonkey Mobile. Tried both on W32 as well as my Nexus4 (Android 4.4.4).

Problem: when loading an image from the clientdataset I get the following errors 1. Remote error: [FireDAC]{Phys][fB]-306. Command text must not be empty. (Connection) 2. Socket Error, even though the CDS does already contain the data (No connection)

Firebird DB --> Firedac --> Datasnap [server] --> DBX connection --> DSProviderconnection --> Clientdatasets

The datasetprovider on the server has the following options set: - poFetchBlobsOnDemand - poAllowCommandText

The loaded field is indeed a blob field and does contain data.

if  DM_OD.CDS_QEmballage.FieldByName('AFBEELDING').IsBlob then
begin
  if  DM_OD.CDS_QEmballage.FieldByName('AFBEELDING').IsNull then
  begin
    showmessage('Empty!'); //for testing puropses
  end
  else
  begin
    try
      BF := DM_OD.CDS_QEmballage.FieldByName('AFBEELDING') as TBlobfield;
      BS := DM_OD.CDS_QEmballage.CreateBlobStream(BF, bmRead); //error message
      self.Items[i].EmbalPic.LoadFromStream(BS);
    finally
      BS.Free;
    end;
  end;
end;

Try this:

var
  ms: TMemoryStream;
begin
  ms := TMemoryStream.Create;
  try
    TBlobField( DM_OD.CDS_QEmballage.FieldByName('AFBEELDING') ).SaveToStream( ms );
    self.Items[i].EmbalPic.LoadFromStream( ms );
  finally
    ms.Free;
  end;
end;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM