完全代码是这样的:
procedure TForm1.Button1Click(Sender: TObject);
var
sfilename:string;
function BlobContentToString(const filename:string):string;
begin
with Tfilestream.Create(filename,fmopenread) do
try
begin
setlength(Result,size);
read(pointer(Result)^,size);
end;
finally
free;
end;
end;
begin
opendialog1.Execute;
sfilename:=opendialog1.FileName;
adotable1.Edit;
adotable1.FieldByName('image').AsString:=blobcontenttostring(sfilename);
adotable1.Post;
end;