- Can I store the image in the access link?
- If so, how then can this image be output to Delphi7 via Image?
- one1. Yes. 2. Load into memory and output. What exactly did you try and what did not work out? - kot-da-vinci
- I tried through dbimage, saved the image in bmp in the OLE field in the bmp field, but when I started it produced an error bmp image is not valid. - Andrei
2 answers
I did not quite understand what it means by reference.
However, you can both store and read. Below is an example of saving in the database and display using ADO. Weakly whacked like a proof-of-concept.
uses jpeg; ... procedure TForm1.ADOQuery1AfterScroll(DataSet: TDataSet); var j : TJPEGImage; b : TADOBlobStream; begin j := TJPEGImage.Create(); b := TADOBlobStream.Create( TBlobField( ADOQuery1.FieldByName('IMG') ), bmRead ); try j.LoadFromStream( b ); Image1.Picture.Assign( j ); finally b.Free(); j.Free(); end; end; procedure TForm1.Button1Click(Sender: TObject); var s : TFileStream; c : TADOCommand; begin s := TFileStream.Create( 'e:\temp\image.jpg', fmOpenRead ); c := TADOCommand.Create( nil ); try c.Connection := ADOConnection1; c.CommandText := 'insert into Table1 ( IMG ) values ( :IMG );'; c.Parameters.ParamByName( 'IMG' ).LoadFromStream( s, ftBlob ); c.Execute(); finally c.Free(); s.Free(); end; end; There are 5 methods for storing information in the database
1) Storage as OLE objects. Disadvantages - large volume, the need to install a set of relevant applications. Dignity - ease of use Example: the Northwind training base In the beginning, everyone uses. Then, depending on the tasks. And the number and volume of drawings.
2) Storage in binary DIB format in the field of OLE objects. Disadvantages - a large amount, the need to write additional code to load images into the database (but the code is not too complex, there are typical practices). Dignity - the speed of the withdrawal of images. Used rarely because compared to the first method, the base volume does not decrease, and the complexity of programming increases.
3) Storage in compressed binary DIB format in the field of OLE objects. Disadvantages - it is necessary to use or develop the data archiving system itself, an additional code. Dignity - a smaller amount of database compared with the first two methods. Example: sd_Foto.zip using the zlib.dll library. or sd_dbFoto3_97.zip zlib.dll library for Win2000 Pro and WinXP: zlib123dll.zip
4) Store files in JPG and GIF format in the field of OLE objects and load them into the Image control (figure) through a temporary file. Disadvantages - it is necessary to use a temporary file to load the picture, increase the picture load time, additional code. Dignity - a smaller amount of database compared with the first three methods. Example: pictures.rar or sd_dbFoto4_97.zip
5) Storage in the database of the paths to the pictures in the JPG and GIF format and their loading into the Image control (Figure). Disadvantages - it is necessary to monitor the integrity of the set of figures, increase the loading time of the image, additional code. Dignity - the smallest amount of database compared with the first four ways. Example: sd_dbFoto5_97.ZIP
For display in JPG and GIF format, for example, the DBImage component is suitable.