也来谈谈数据库中的图象存取[2]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 davidlove 的 blog

">  property name:string read fname write fname;

  property idcard:string read fidcard write fidcard;
  property sex:byte read fsex write fsex;
  property photo:timage read fphoto write fphoto;
  property query:tquery read fquery write fquery;
  property database:tdatabase read fdatabase write fdatabase;
function thuman.insert: boolean;
var
  sqlstr:string;
  lstream:tmemorystream;
  lpicture:tjpegimage;
begin
  lstream:=tmemorystream.create;
  lpicture:=tjpegimage.create;
// fphoto为timage变量,在主界面可以选择一张照片  
 if fphoto.picture.graphic<>nil then
  begin
    lpicture.assign(fphoto.picture.graphic);
    lpicture.savetostream(lstream);
  end;  
  if fdatabase.intransaction then fdatabase.commit;
  fdatabase.starttransaction;
  query.sql.text:= 'insert into human(name,idcard,sex,photo) values(:name,:idcard,:sex,:photo)’;
  子段前加冒号,动态生成sql参数,然后给参数赋值:
  query.parambyname('name').asstring:=’张家恶少’;
  query.parambyname('idcard').asstring:=something;
  query.parambyname('sex').asstring:=something;
本文关键:数据库 图象 SQL 动态参数
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top