2006. december 28., csütörtök

How can I read a BlobStream with TADOQuery from an AccessDB?

Problem/Question/Abstract:

How can I read a BlobStream with TADOQuery from an AccessDB?

Answer:

// Torry's Delphi Tips - Database
// Author Peppa
// Listed 14.05.2003

function GetBlobStream(Query: TADOQuery): TMemoryStream;
begin
result := TMemoryStream.Create;

// You must connect to AccessDB first.
// See: Query.Connection, TADOConection or Query.ConnectString

// Send SQL command
Query.Active := False;
Query.SQL.Clear;
// data is my row and email the table
Query.SQL.Append('SELECT data FROM email WHERE id=1');
Query.Active := True;

Result.LoadFromStream(Query.CreateBlobStream(Query.FieldByName('Data'), bmRead));
end;


Nincsenek megjegyzések:

Megjegyzés küldése