(1)存入
sql:='insert into 表1(姓名,备注,图片,类型) values("'+name+'","'+more+'",:pic,"'+uppercase(ExtractFileExt(self.pic))+'")';
form1.ADOQuery1.Close;
form1.ADOQuery1.SQL.Clear;
form1.ADOQuery1.SQL.Add(sql);
//self.pic是图片的路径
form1.ADOQuery1.Parameters.ParamByName('pic').LoadFromFile(self.pic,ftBlob);
form1.ADOQuery1.ExecSQL;
(2)提取
//在内存中开辟一个临时流存储空间
ms:=TMemoryStream.Create;
(self.ADOQuery1.FieldByName('图片') as TBlobField).SaveToStream(ms);
//重要,不然读不到数据
ms.Position:=0;
self.Image1.Picture.Bitmap.LoadFromStream(ms);
ms.Free;
图片如下:
sql:='insert into 表1(姓名,备注,图片,类型) values("'+name+'","'+more+'",:pic,"'+uppercase(ExtractFileExt(self.pic))+'")';
form1.ADOQuery1.Close;
form1.ADOQuery1.SQL.Clear;
form1.ADOQuery1.SQL.Add(sql);
//self.pic是图片的路径
form1.ADOQuery1.Parameters.ParamByName('pic').LoadFromFile(self.pic,ftBlob);
form1.ADOQuery1.ExecSQL;
(2)提取
//在内存中开辟一个临时流存储空间
ms:=TMemoryStream.Create;
(self.ADOQuery1.FieldByName('图片') as TBlobField).SaveToStream(ms);
//重要,不然读不到数据
ms.Position:=0;
self.Image1.Picture.Bitmap.LoadFromStream(ms);
ms.Free;
图片如下:
回复Comments
{commenttime}{commentauthor}
{CommentUrl}
{commentcontent}