begin
try
Stream := TMemoryStream.Create// 创建内存流Image1.Picture.Graphic.SaveToStream(Stream) // 将图片保存到内存流中
adoquery1.Close adoquery1.SQL.Clear adoQuery1.SQL.Add('Insert into test3 values (:id,:photo)') ADOQuery1.Parameters.ParamByName('id').Value := editId.Text adoQuery1.Parameters.ParamByName('photo').LoadFromStream(Stream,ftBlob)// 读取保存的内存图adoquery1.ExecSQL
finally
Stream.Free// 释放内存流
end
end
access保存图标的字段设置为ole对象;ms:TMemoryStream
begin
ms:=TMemoryStream.Create
imgMem.Picture.Graphic.SaveToStream(ms)//将image控件中的图片加载到流
//添加照片
s := 'INSERT INTO T_Pic (F_PicID,F_PicImage) values (:pid,:pimage)'
with query do
begin
Close
SQL.Clear
SQL.Add(s)
Parameters.ParamByName('pid').Value := memID
Parameters.ParamByName('pimage').LoadFromStream(ms,ftBlob)
ExecSQL
end
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)