Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread BLOB Field
Sun, May 26 2013 9:14 AMPermanent Link

Enrico Pettenati

I need to load a picture in the database, i'm using DBElevate with Delphi XE2.
With Elevate DBManager i can load a picture and then i can see that from my application.
Using a OpenPictureDialog procedure i can load in the DBImage component, but that is not saved on the database.
Have some some idea ?
Regrads
Sun, May 26 2013 6:04 PMPermanent Link

Barry

Enrico,

See this link:
http://www.elevatesoft.com/forums?action=view&category=edb&id=edb_sql&msg=5782&start=1&keywords=blobfield%20image&searchbody=True&forum=EDB_Announce&forum=EDB_General&forum=EDB_SQL&forum=EDB_Connect&forum=EDB_Extensions&forum=EDB_Beta&forum=EDB_Binaries&forum=EDB_Suggestions&forum=EDB_ThirdParty&forum=EDB_Discussion#5782

Barry


------------------
From Tim:

In that case, just use a parameterized query, like this:

with MyEDBQuery do
  begin
  SQL.Text:='INSERT INTO ATableName (APKField, ABLOBField) VALUES (NULL,
:BlobField)';
  Prepare;
  ParamByName('BlobField').LoadFromFile('c:\myimage.png',ftBlob);
  ExecSQL;
  end;

That is the easiest way to load a BLOB from the local machine via an INSERT
statement.
Mon, May 27 2013 2:41 PMPermanent Link

Enrico Pettenati

Thanks,
one more question !
I'm working with EDBTables, can i insert a Blob using Tables or i need change my way to work ?
Regards
Enrico

Barry wrote:

Enrico,

See this link:
http://www.elevatesoft.com/forums?action=view&category=edb&id=edb_sql&msg=5782&start=1&keywords=blobfield%20image&searchbody=True&forum=EDB_Announce&forum=EDB_General&forum=EDB_SQL&forum=EDB_Connect&forum=EDB_Extensions&forum=EDB_Beta&forum=EDB_Binaries&forum=EDB_Suggestions&forum=EDB_ThirdParty&forum=EDB_Discussion#5782

Barry


------------------
From Tim:

In that case, just use a parameterized query, like this:

with MyEDBQuery do
  begin
  SQL.Text:='INSERT INTO ATableName (APKField, ABLOBField) VALUES (NULL,
:BlobField)';
  Prepare;
  ParamByName('BlobField').LoadFromFile('c:\myimage.png',ftBlob);
  ExecSQL;
  end;

That is the easiest way to load a BLOB from the local machine via an INSERT
statement.
Tue, May 28 2013 6:21 AMPermanent Link

Uli Becker

Enrico,

you habe to use a stream to store data in a blob field.

I use this code e.g. to store rtf to a blob field:

procedure TBefundEditDiktatForm.btnSaveRTFClick(Sender: TObject);
var
  MyStream: TMemoryStream;
begin
  MyStream := TMemoryStream.Create;
  try
    ReDiktat.Lines.SaveToStream(MyStream);
    MyStream.position := 0;
    WizBefundForm.CurrentBefundQuery.Edit;
    WizBefundForm.CurrentBefundQueryDiktatText.LoadFromStream(MyStream);
    WizBefundForm.CurrentBefundQuery.Post;
  finally
    MyStream.Free;
  end;
end;

Uli
Image