请大家帮忙(怎么插入图片)(50分)

  • 主题发起人 主题发起人 abraveboy
  • 开始时间 开始时间
A

abraveboy

Unregistered / Unconfirmed
GUEST, unregistred user!
Stream := TStream.Create();<br> { with Query1 do<br> &nbsp;begin<br> &nbsp;close;<br> &nbsp;sql.clear;<br> &nbsp;sql.add('select * from GProfilesExt where ProfileNo =:ProfileNo');<br> &nbsp;ParamByName('ProfileNo').asstring := QuotedStr('G000006975');<br> &nbsp;open;<br> &nbsp; &nbsp;end;}<br> &nbsp; &nbsp;FAccount := 'G000006975';<br> &nbsp;with Query1 do<br> &nbsp;begin<br> &nbsp;close;<br> &nbsp;sql.clear;<br> &nbsp;sql.add('select * from GProfilesExt where ProfileNo='+QuotedStr(FAccount));<br> &nbsp;open;<br><br> &nbsp; TBlobField(FieldByName('CertImage')).SaveToStream(Stream);<br> &nbsp;// Stream := TBlobStream.Create(TBlobField(FieldByName('CertImage')),bmRead);<br><br> &nbsp;//ParamByName('CertImage')as TBlobFiedl).SaveToStream(Stream);<br> &nbsp;//或<br><br> &nbsp;with Query2 do<br> &nbsp;begin<br><br> &nbsp;close;<br> &nbsp;sql.clear;<br> &nbsp;sql.add('insert into Image_test(Image) values(:Image)');<br> &nbsp;TBlobField(ParamByName('Image')).LoadFromStream(Stream);<br> &nbsp;execSql;<br> &nbsp;end;<br> &nbsp;end;<br> &nbsp;Stream.Free;
 
你到底要干什么?<br>I Full U
 
TO HuangJH:你好,我要做从数据库中一个Image类型的字段,取出把它存到另一个表的image类型的字段中<br>请大哥帮忙
 
var<br> &nbsp;TempJPEG:TJpegImage;<br> &nbsp;LStream:TMemoryStream;<br>begin<br> &nbsp;Result:=False;<br> &nbsp;TempJPEG:=TJpegImage.Create;<br> &nbsp;try<br> &nbsp; &nbsp;LStream:=TMemoryStream.Create;<br> &nbsp; &nbsp;Try<br> &nbsp; &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp; &nbsp;TBlobField(ADOQuery1.FieldByName('Photo')).SaveToStream(LStream);<br> &nbsp; &nbsp; &nbsp; &nbsp;LStream.Seek(0, soFromBeginning);<br> &nbsp; &nbsp; &nbsp; &nbsp;TempJPEG.LoadFromStream(LStream);<br> &nbsp; &nbsp; &nbsp; &nbsp;imgPhoto.Picture.Bitmap.Assign(TempJPEG);<br> &nbsp; &nbsp; &nbsp;finally<br> &nbsp; &nbsp; &nbsp; &nbsp;LStream.Free;<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp;Except<br> &nbsp; &nbsp; &nbsp;Exit ;<br> &nbsp; &nbsp;end; &nbsp;<br> &nbsp;finally<br> &nbsp; &nbsp;TempJPEG.Free;<br> &nbsp;end;<br> &nbsp;Result:= True;<br><br><br>要存在另一张表中 <br><br>var<br> &nbsp;sPath:String;<br>begin<br> &nbsp;SavePictureDialog1.InitialDir:='C:';<br> &nbsp;if SavePictureDialog1.Execute &nbsp;then<br> &nbsp;Begin<br> &nbsp; &nbsp;sPath:=SavePictureDialog1.FileName;<br> &nbsp; &nbsp;imgPhoto.Picture.LoadFromFile(sPath);<br> &nbsp; &nbsp;imgPhoto.Picture := Nil;<br> &nbsp; &nbsp;end<br> &nbsp; &nbsp;else<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;if DataSource1.State=DSBrowse then DataSource1.Edit;<br> &nbsp; &nbsp; &nbsp;Adoquery1.Append ; &nbsp;<br> &nbsp; &nbsp; &nbsp;TBlobField(Adoquery1.FieldByName('Photo')).LoadFromFile(sPath);<br> &nbsp; &nbsp; &nbsp;imgPhoto.Stretch:=true;<br> &nbsp; &nbsp; &nbsp;Adoquery1.Post;<br> &nbsp; &nbsp;end<br> &nbsp;end;
 
后退
顶部