Delphi程序
ADOQuery1的sql為'select * from test'
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,JPEG,StdCtrls, Buttons, ExtCtrls, DB, ADODB;
type
TForm1 = class(TForm)
Image1: TImage;
BitBtn1: TBitBtn;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
ADOQuery1image: TBlobFIEld;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
jpeg:TJpegImage;
mem:TmemoryStream;
begin
mem:=TmemoryStream.Create;
mem.LoadFromFile('E:AdobeAdobe1.jpg');
ADOQuery1.Insert;
TBlobField(ADOQuery1.FIEldByName('Image')).LoadFromStream(mem);
ADOQuery1.Post;
mem.Free;
ADOQuery1.First;
jpeg:=TJpegImage.Create;
TBlobField(ADOQuery1.FIEldByName('image')).SaveToFile('E:aa.jpg');
jpeg.LoadFromFile('E:aa.jpg');
Image1.Picture.Assign(jpeg);
jpeg.Free;
deleteFile('E:aa.jpg');
end;
end.
一定要Use JPEG!!!!
通過這個方法,任何可被操作系統識別的文件,都可以載入載出到數據庫。