Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Saving to BLOB field in dbExpress with a join

Posted on 2003-11-13
2
Medium Priority
?
939 Views
Last Modified: 2008-01-16
Writing to and from Interbase BLOB fields in Delphi7 like this….

Memo.Text:=ClientDataset.FieldByName(‘NOTES’).AsString;
and
ClientDataset.FieldByName(‘NOTES’).AsString:=Memo.Text;

...works fine until the underlying dataset is a join and the fields need to be written explicitly to the joined tables by the providers BeforeUpdateRecord event.
Building SQL statements in this event from the fields to be updated works for non-blob field but doesn’t work for BLOB fields as there is no INSERT syntax allowable for BLOB fields.
The question is therefore what should the providers BeforeUpdateRecord event look like to handle this kind of field? Is it possible to do it this way or is there another way?
A solution involving the datasets provider is preferable as this nicely encapsulates updates to all affected tables.
0
Comment
Question by:RogerFroud
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
RogerFroud earned 0 total points
ID: 9782120
This solution seems to work ok but is a bit clumsy. Any better solution gets the points....

Dataset Provider BeforeUpdateRecord event
var
    SQL: String;
    myParams: TParams;
    FileStream : TFileStream; //debug only
    StringStream : TStringStream;
......
code to save all other fields using INSERT statements in SQL then....

      if (DeltaDS.FieldByName('NOTES').NewValue<>Null) then
        begin
          myParams := TParams.Create;
          myParams.Clear;
          myParams.CreateParam(ftBlob, 'BlobParam', ptInput);
          StringStream:=TStringStream.Create(DeltaDS.FieldByname('NOTES').NewValue);
          myParams.ParamByName('BlobParam').LoadFromStream(StringStream, ftBlob);
          StringStream.Free;
          SQL:=Format('UPDATE STOCKSUPPLIERS SET NOTES = :BlobParam WHERE STOCKSUPPLIERID = %d', [ID]);
          Connection.Execute(SQL, myParams);
          myParams.Free;
        end;
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question