// save the image to a database function imagesavetosql (dataset: TQuery; filename: String): boolean; var imagejpg: TJPEGImage; // jpg picture MyStm: TMemoryStream; begin result: = false; MyStm: = TMemoryStream.Create; imagejpg: = Tjpegimage .Create; if filename <> '' then begin imagejpg.LoadFromFile (filename); MyStm.Position; (MyStm) imagejpg.SaveToStream: = 0; TBlobField (dataset.FieldByName ( '. pict')) LoadFromStream (MyStm); / / Don't be able to have a TDIRECTORYLISTBOX, TGAGE control (CHK_ROAD), which only supports BMP Result: = true; end; mystm.free; imagejpg.free; end; // BitBtn2Click (Sender: TObject); var dirlist: TStringList; i: Integer; begin inherited; if chk_road.Checked then begin dirlist: = TStringList.Create; dirlist.Clear; try GetAllFileName (DirectoryListBox1.Directory, dirlist); if dirlist.Count > 0 THEN Begin Gauge1.minvalue: = 0; Gauge1.MaxValue: = dirlist.count-1; for i: = 0 to dirlist.count-1 do begin with dm.qry_pict do begin insert; Fields [0] .sstring: = Copy (Dirlist.strings [i], 1, POS ('.', Dirlist.strings [i]) - 1); if ImageSavetosql (DM.QRY_PICT, DIRLIST.STRINGS [I]) = False Then Begin ShowMessage ('Import' Dirlist.Strings ") [i] '. error'); Abort; end; post; end; // with gauge1.addprogress (1); end; // for end // if else showmessage ('does not exist in the directory "); Finally Dirlist.free; end;
ELSE ShowMessage ('Please perform the path selection operation');
// close;