看看吧,我是可以的,不知適合你不
function SaveBlobField(Field: TField; const FileName: String): Boolean;
function BlobContentToString(const FileName: String): String;
begin
with TFileStream.Create(FileName, fmOpenRead) do
try
SetLength(Result, Size);
Read(Pointer(Result)^, Size);
finally
Free;
end;
end;
begin
Result := True;
try
Field.AsVariant:= BlobContentToString(FileName);
except
Result := False;
end;
end;
Instance
procedure TfrmXT.btnTPClick(Sender: TObject);
var fileName:string;
begin
inherited;
if diaPic.Execute then
fileName:=diaPic.FileName ;
DM.XT.edit;
try
SaveBlobField(DM.XT.FieldByName('XT_TP'),fileName);
DM.XT.UpdateBatch();
except
showmessage('圖片添加未成功');
end;
end;