Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TAdoTable and BLOB 2

Status
Not open for further replies.

ladoota

Technical User
Jun 14, 2002
2
0
0
SI
I have ADOTable with a BLOB field(i.e. field no 3, name 'blobfield'). I was trying different things in order to retreive field's content into memory buffer or int file, I am afraid without success.

Help would be appreciated.

Beside while I was looking on the web, trying to find some help with above, everything was either too cryptic or asumed level of knowledge much higher than I happen to have. If anyone can point me to URL or to book which covers the ADO in some detail, I'd appreciate it (and, yes, I know about the delphi.about.com articles).

Regards, Vladimir
 
This is just out off my head, but it should work.
(It needs some exception handling and error checking though)
The reason I included the ID field in the select statement is that ADO sometime fails if you select a memo/blob field all by itself.

procedure ReadBlob;
type
TBuf = array[0..0] of byte; //Range checking must be off when working with [0..0] arrays
var
fldBlob : TBlobField;
Buf : ^TBuf;
Stream : TMemoryStream;
begin
Query.SQL.Text := 'SELECT ID, MYMEMO FROM MyTable WHERE ID = 1';
Query.Open;
fldBlob := Query.Fields[1];
Query.Close;
Stream := TMemoryStream.Create;
fldBlob.SaveToStream(Stream);
BufSize := Stream.Size;
GetMem(Buf, BufSize);
Stream.Write(Buf^, Stream.Size);
Stream.Free;

//do something with the buffer here

FreeMem(Buf, BufSize);
end;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top