|  | 
 
 发表于 2011-12-16 08:38:39
|
显示全部楼层 
回 3楼(凡人晓悟) 的帖子
| zero有问题?俺怎么没碰上?凡人晓悟:自已解决了,是zero控件的问题我用lazarus自带的sqliteconn连接就解决了。 (2011-12-16 01:59)
 复制代码uses  classes, sysutils, db, fileutil, forms, controls, graphics, dialogs, DbCtrls,  StdCtrls, Buttons, ZConnection, ZDataset, ZAbstractDataset,lconvencoding,fpimage;type  { tform1 }  tform1 = class(tform)    datasource1: tdatasource;    dbtxtid: TDBEdit;    dbtxtpath: TDBEdit;    dbimage1: tdbimage;    dbnavigator1: tdbnavigator;    label1: tlabel;    label2: tlabel;    opendialog1: topendialog;    speedbutton1: tspeedbutton;    zconnection1: tzconnection;    zquery1: tzquery;       procedure writeimagetodb;    procedure readimagefromdb;  private    { private declarations }  public    { public declarations }  end;var  form1: tform1;  fstream:tstream;  fpicture:tjpegimage;implementation{$R *.lfm}{ tform1 }procedure tform1.writeimagetodb;begin  try    tblobfield(zquery1.fieldbyname('picture')).LoadFromFile(utf8tocp936(dbtxtpath.text));  except    on e:exception do    showmessage(e.Message);  end;end;procedure tform1.readimagefromdb;begin  if not (tblobfield(zquery1.FieldByName('picture')).IsNull) then     begin       fstream:=zquery1.CreateBlobStream(zquery1.FieldByName('picture'),bmread);       fpicture:=tjpegimage.create;       try       fpicture.LoadFromStream(fstream);       dbimage1.Picture.Assign(fpicture);       finally         fstream.Free;         fpicture.Free;       end;     end;end;
 | 
 |