delphi,怎么将图片插入到数据库?
1个回答
展开全部
var Picms:TMemoryStream;
begin
Picms:=TMemoryStream.Create ;
Img_Pic.Picture.Graphic.SaveToStream(Picms);
SaveSql:='Insert into lvshi(编号,姓名,照片) values('
+''''+Trim(LEdit_bh.Text)+''''+',' //编号
+''''+Trim(LEdit_xm.Text)+''''+',' //姓名
+':photo'+')'; //照片
ADOQ_List.Close;
ADOQ_List.SQL.Clear;
ADOQ_List.SQL.Add(SaveSql);
ADOQ_List.Parameters.ParamByName('photo').LoadFromStream(Picms,ftBlob);
ADOQ_List.ExecSQL;
Picms.Free;
end;
begin
Picms:=TMemoryStream.Create ;
Img_Pic.Picture.Graphic.SaveToStream(Picms);
SaveSql:='Insert into lvshi(编号,姓名,照片) values('
+''''+Trim(LEdit_bh.Text)+''''+',' //编号
+''''+Trim(LEdit_xm.Text)+''''+',' //姓名
+':photo'+')'; //照片
ADOQ_List.Close;
ADOQ_List.SQL.Clear;
ADOQ_List.SQL.Add(SaveSql);
ADOQ_List.Parameters.ParamByName('photo').LoadFromStream(Picms,ftBlob);
ADOQ_List.ExecSQL;
Picms.Free;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询