Access 小問題.20塊打洋(20分)

  • 主题发起人 主题发起人 Rechard3000
  • 开始时间 开始时间
R

Rechard3000

Unregistered / Unconfirmed
GUEST, unregistred user!
怎樣存取圖形(*.jpg,*.gif,*.bmp等等).必須存在數據庫中
 
1)图像倒入DBImage1
procedure TpfEditForm.DBImage1DblClick(Sender: TObject);
var
Path: String;
begin
if OpenDialog1.Execute then
begin
Path := OpenDialog1.FileName;
if Not (DMForm.adoqrypf.State in [dsInsert,dsEdit]) then
DMForm.adoqrypf.Edit;
try
DBImage1.Picture.LoadFromFile(Path);
except
ShowMessage('不是有效的文件');
end;
end;
end;

存储(access)(use 重要有jpeg,DBImage1的Datasource,和字段是空的)
procedure TDMForm.adoqrypfBeforePost(DataSet: TDataSet);
var
MyJPEG: TJPEGImage;
Ms: TMemoryStream;
begin
if pfEditForm.pictureTF then
begin
MyJPEG := TJPEGImage.Create;
try
MyJPEG.Assign(pfEditForm.DBImage1.Picture.Graphic);
Ms := TMemoryStream.Create;
MyJPEG.SaveToStream(Ms);
Ms.Position := 0;
TBlobField(adoqrypf.FieldByName('picture')).LoadFromStream(Ms);
finally
MyJPEG.Free;
MS.Free;
end;
end;
end;
显示
procedure TpfEditForm.FormShow(Sender: TObject);
var
tempStream: TStringStream;
tempJpeg: TJpegImage;
begin
if (DMForm.adoqrypf['picture'] <> '') and (DMForm.adoqrypf['picture'] <> null) then
try
tempStream := TStringStream.Create('');
TBlobField(DMForm.adoqrypf.FieldByName('picture')).SaveToStream(tempStream);
tempStream.Position := 0;
TempJpeg := TJpegImage.Create;
TempJpeg.LoadFromStream(tempStream);
DBImage1.Picture.Bitmap.Assign(TempJpeg);
finally
tempStream.Free;
tempJpeg.Free;
end;
end;
 
這麼簡單的問題,只有一個人回覆。20塊大洋給你了,提子兄。
 
后退
顶部