Delphi存取图片
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DBXpress, DBCtrls, StdCtrls, DB, DBClient,
Grids, DBGrids,ExtCtrls, ADODB,
jpeg;
type
TForm1 = class(TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
Label1: TLabel;
ADOTable1ID: TIntegerField;
ADOTable1files: TBlobField;
ADOTable1filename: TWideStringField;
DBImage1: TDBImage;
DBNavigator1: TDBNavigator;
Button1: TButton;
OpenDialog1: TOpenDialog;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
ADOTable1.Edit;
ADOTable1files.LoadFromFile(OpenDialog1.FileName);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
JPEGImage:TJPEGImage;
begin
JPEGImage:=TJPEGImage.Create; //创建JPEG图像对象
if OpenDialog1.Execute then
try
JPEGImage.LoadFromFile(OpenDialog1.FileName); //从文件中装载jpg图像,
ADOTable1.Edit;
DBImage1.Picture.Bitmap.Assign(JPEGImage); //将jpg导入
ADOTable1.Post;
finally
JPEGImage.Free; //释放对象
end;
end;
end.
此段代码好用,但是应用的数据库是Access我想问一下在Sql里怎么改阿!!!!!!!!!!