Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 4 of 4 total |
Save an image to a Blob field. |
Mon, Jul 19 2021 2:33 AM | Permanent Link |
Ian Branch | Hi Team,
D10.4.2, latest EDB. I have the following code.. {code} // pImage := TBitMap.Create; AASC1.SaveToBitmap(pImage); // dmPV.PVSignatures.Open; dmPV.PVSignatures.Appendrecord([iPVNo, iPONo, Trim(DBEdit3.Text), pImage, now]); dmPV.PVSignatures.Close; // {code} The fourth field in the append is a Blob field called Signatures. This works fine. I now need to be able to save the pImage direct to the Signatures field. i.e. {code} // pImage := TBitMap.Create; AASC1.SaveToBitmap(pImage); // dmPV.PVSignatures.Open; dmPV.PVSignatures.Edit; dmPV.PVSignatures.FieldByName('Signatures').AsXxxxxx := pImage; dmPV.PVSignatures.Post; dmPV.PVSignatures.Close; // {code} Now, there is no .AsBlob option nor does .AsVariant work. How can I get this to work please? Regards & TIA, Ian |
Mon, Jul 19 2021 7:11 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Ian
Its a while (like DBISAM ago) since I did this an back then you just did .AsString. The modern approach is to create a memory stream (preferably TEDBBlobStream) , load the image into there, assign it to the field in question and then dispose of the memory stream. Here's an example posted by Uli ages ago AttachmentStream := TEDBBlobStream.Create(dm.FilesTableBinary, bmread); try FileStream := TFileStream.Create(FullTempPath, fmCreate); try FileStream.CopyFrom(AttachmentStream, 0); finally FileStream.free; end; finally AttachmentStream.free; end; Its also worth having a look in the manual under TEDBBlobStream. Finally, if you're using my subclassed table adding a BLOB updater would be fairly easy. Roy Lambert |
Mon, Jul 19 2021 3:54 PM | Permanent Link |
Ian Branch | Thanks Roy,
>>Finally, if you're using my subclassed table adding a BLOB updater would be fairly easy Ummm. Fancy a challenge for TnlhTable & TnlhQuery? Regards, Ian |
Wed, Aug 4 2021 7:51 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Ian,
<< I now need to be able to save the pImage direct to the Signatures field.>> You should be able to use this: TBlobField(dmPV.PVSignatures.FieldByName('Signatures')).Assign(pImage); Any class that implements the IStreamPersist interface can be assigned to a BLOB field (TBlobField), and that includes all TGraphic descendant classes like TBitmap. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Friday, May 3, 2024 at 06:06 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |