Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 10 of 12 total |
How to save binary data using sql... |
Mon, Jan 26 2009 6:06 PM | Permanent Link |
Uli Becker | Hi,
I am using this code to save an email-attachment in a table: dm.AttachmentsTable.append; dm.AttachmentsTableFilename.asString := MessagePart.FileName; try SaveStream := TEDBBlobStream.create(dm.AttachmentsTableBinary, bmWrite); MessagePart.SaveToStream(SaveStream); finally SaveStream.free; end; dm.AttachmentsTable.post; How can I do the same by using a query? Regards Uli |
Sun, Feb 8 2009 9:24 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Uli,
<< How can I do the same by using a query? >> You would need to use a parameterized UPDATE statement to do so, or use one big literal UPDATE statement with the binary data as a constant. If you can tell me your preference, I can offer some code. -- Tim Young Elevate Software www.elevatesoft.com |
Sun, Feb 8 2009 2:48 PM | Permanent Link |
Ulrich Becker | Tim
> You would need to use a parameterized UPDATE statement to do so, or use one > big literal UPDATE statement with the binary data as a constant. If you can > tell me your preference, I can offer some code. I'd prefer a parameterized update statement. Thanks for a code snippet. Uli |
Mon, Feb 9 2009 5:59 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Uli,
<< I'd prefer a parameterized update statement. Thanks for a code snippet. >> This should do it (I noticed that you were doing an INSERT, not an UPDATE, but they both work the same way in terms of the parameters): with MyEDBQuery do begin SQL.Text:='INSERT INTO Attachments (FileName, Contents) VALUES (:FileName, :Contents)'; Prepare; ParamByName('FileName').AsString:=MessagePart.FileName; TempStream:=TMemoryStream.Create; try MessagePart.SaveToStream(TempStream); ParamByName('Contents').LoadFromStream(TempStream,ftBlob); finally FreeAndNil(TempStream); end; ExecSQL; end; -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Feb 10 2009 1:34 AM | Permanent Link |
Uli Becker | Tim,
thank you for the code! Regards Uli |
Tue, Feb 10 2009 4:04 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Tim
>with MyEDBQuery do > begin > SQL.Text:='INSERT INTO Attachments (FileName, Contents) VALUES >(:FileName, :Contents)'; > Prepare; > ParamByName('FileName').AsString:=MessagePart.FileName; > TempStream:=TMemoryStream.Create; > try > MessagePart.SaveToStream(TempStream); > ParamByName('Contents').LoadFromStream(TempStream,ftBlob); > finally > FreeAndNil(TempStream); > end; > ExecSQL; > end; Out of interest could you do something like ParamByName('Contents').AsString := ' X''01F21028''; Roy Lambert |
Tue, Feb 10 2009 8:17 AM | Permanent Link |
Uli Becker | Roy
> Out of interest could you do something like ParamByName('Contents').AsString := ' X''01F21028''; I am using the idMessage component by Indy and it allows .SaveToFile or ..SaveToStream. Uli |
Tue, Feb 10 2009 8:40 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Uli
>I am using the idMessage component by Indy and it allows .SaveToFile or >.SaveToStream. Fair enough - but I'm still interested. Roy Lambert |
Tue, Feb 10 2009 12:12 PM | Permanent Link |
Uli Becker | Roy ,
> Fair enough - but I'm still interested. Probably my English is not good enough - but I don't understand what you mean. Uli |
Tue, Feb 10 2009 1:15 PM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Uli
>> Fair enough - but I'm still interested. > >Probably my English is not good enough - but I don't understand what you >mean. OK - fuller version. I'm pleased that Tim's answer solved your query (that's "fair enough"). It could also mean that you've stated a fact that is of little or no interest to me - not in any nasty way though. The second bit "but I'm still interested" means that even though Tim's answer has satisfied your query and hence Tim doesn't need to answer my question to help you I'd still like to know the answer out of general interest. Hope that helps. Roy Lambert |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Saturday, May 4, 2024 at 09:18 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |