Jump to content
Bob Perkins

FIREDAC Retrieving To Stream

Recommended Posts

I'm using an MS SQL database to store large files in a table.  The files are too large for binding to a field directly.  It has to go through a command just like the update to get it into the database.  No exception is raised but the function returns false.  I am finding it difficult to find an answer with Google search.  Any help would be apprciated.



      RIMSDBFireDac.StartTransaction;
      try
        with DCaseAttach do
        begin
          FireDacQuery.SQL.Text := 'SELECT :p = ''D:\TEMP\TEMP.MP4'' FROM caseattach WHERE id = :id';
          FireDacQuery.Params[0].DataType := ftStream;
          FireDacQuery.Params[0].FDDataType := dtHBFile;
          FireDacQuery.Params[0].ParamType := ptOutput;
          FireDacQuery.Params[0].StreamMode := smOpenRead;
          FireDacQuery.Params[1].AsInteger := CaseN;
          if FireDacQuery.OpenOrExecute then
            FireDacQuery.Params[0].AsStream.Read(Buffer, AttachSize)
          else
            ErrorMsg('OpenOrExecute failed.');
        end;
        RIMSDBFireDac.Commit;
      except
        on E: Exception do
          begin
            ErrorMsg('<PullImageFromDB on pulling photo> ' + E.Message);
            RIMSDBFireDac.Rollback;
          end;
      end;
 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×