#1 2014-03-05 21:47:13

Celso
Member
Registered: 2013-05-14
Posts: 55

Save a PDF file in DB

In my application I generate PDF with TPdfDocumentGDI. Must be saved in a BLOB field in my database.
I used like this:

v_pdf: TPdfDocumentGDI;
v_pdfstream: = TMemoryStream.Create;
v_pdf.SaveToStream (v_pdfstream);
v_pdfstream.Position: = 0;
fdQuery.ParamByName ('REQUESTPAGE_PAGES') LoadFromStream (apages, Data.DB.ftBlob).;

How can I do this with mORMot?

I'm trying so, but does not work:

v_pdf: TPdfDocumentGDI;
v_pdfstream: = TMemoryStream.Create;
v_pdf.SaveToStream (v_pdfstream);
v_pdfstream.Position: = 0;
v_prep: Props.NewThreadSafeStatementPrepared = ('INSERT INTO CPU_REQUESTPAGE' +
                                                                          '(REQUESTPAGE_PAGES)' +
                                                                          'VALUES (?)'
                                                                          False);
v_prep.BindBlob (1, pointer (v_pdfstream), v_pdfstream.Size);
v_prep.ExecutePrepared;

Offline

Board footer

Powered by FluxBB