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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read image from MS Access db field

Status
Not open for further replies.

VJar

Programmer
Aug 3, 2002
18
UA
How to read valid bitmap image from MS Access db field, which was
inserted into database with Microsoft Access 2000 Application?
Application saves in database file info + (bitmap) + anotherinfo.
When I create stream, his size is greater than fileStream of image, wich
was inserted into database. Is it impossible to read only bitmap stream part?
 
Hi,
this may help you.
********************************************************
// Put a file into a BlobField
Procedure SalvaFileNelDb(Campo:TField; NomeFile:TFileName);
Var Blob:TStream;
FS:TFileStream;
Begin
If Not (Campo.DataSet.State in dsEditModes)
Then Campo.DataSet.Edit;

Blob := Campo.DataSet.CreateBlobStream(Campo, bmWrite);
Try
blob.Seek(0, soFromBeginning);
FS:=TFileStream.Create(NomeFile, fmOpenRead or fmShareDenyWrite);
try
Blob.CopyFrom(fs, fs.Size)
finally
fs.Free
end;
finally
Blob.Free
end
End;
*******************************
procedure EsportaeMail1Click(Sender: TObject);
Var Blob:TStream;
Nodo:TTreeNode;
begin
// QEmail is a TQuery
Blob := QEMail.CreateBlobStream(QeMail.FieldByName('File'), bmRead);
Try
Blob.Seek(0, soFromBeginning);
With TFileStream.Create(SaveEMailDlg.FileNAme, fmCreate) Do
Begin
Try
CopyFrom(Blob, Blob.Size)
Finally
Free;
End;
End;
Finally
Blob.Free;
End;
end;
********************************************************

Ciao,
GeppoDarkson.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top