• Welcome to Theos PowerBasic Museum 2017.

adofield_getchunk use question

Started by Bob Mechler, July 27, 2009, 04:28:46 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bob Mechler

The code below for PDFDOC works fine in retrieiving a longvarchar field holding a pdf. I'm trying to adapt it to read longvarbinary of the same pdf. I used the ADO_EX_18 example using parameters and it saved the pdf in the LONGVARCHAR and the LONGVARBINARY field.
An SQL 2005 query shows the 0x... in the binary field so I assume it's storing the pdf in the binary field.

I first tried the Ado_Fields_GetItem that worked for the LONGVARCHAR and did not have success. I now am trying to use adofield_getchunk but I don't find an example anywhere. Can anyone help here.

Thanks,

Bob Mechler


      lpField = AdoFields_GetItem(lpFields, "PDFDOC")
      IF ISTRUE lpField THEN
         CALL AdoField_GetValue(lpField, vRes)
         MSGBOX STR$(LEN(VARIANT$(vRes)))
         sBlob = VARIANT$(vRes)
         OPEN "C:\PDFS\SQLTOOLS\SSA.PDF" FOR BINARY AS 1
           PUT$ 1,sBlob
         CLOSE
         AdoRelease lpField
      END IF
      lpField = AdoFields_GetItem(lpFields, "PDFDOCBIN")
      IF ISTRUE lpField THEN
         CALL AdoField_GetChunk(lpField, 100000,vRes)
         MSGBOX STR$(LEN(VARIANT$(vRes)))
         sBlob = VARIANT$(vRes)
         OPEN "C:\PDFS\SQLTOOLS\SSA1.PDF" FOR BINARY AS 1
           PUT$ 1,sBlob
         CLOSE
         AdoRelease lpField
      END IF


Bob Mechler

Did a search and found an example of using adofield_getchunk on an access database bitmap. It seemd a little specialized and wanted to know if it would generally work for a PDF stored in a LongVarBinary field.

I already can do this in a LONGVARCHAR field but just want to know for my own education how it might work with binary data. It's quite possible we will need to store bitmapped document images.

I'm not sure if nulls are in PDF documents and if not, that may be why LONGVARCHAR fields work.

Bob Mechler

José Roca

 
From my reference guide to ADO: http://www.jose.it-berater.org/ado/iframe/index.htm

The syntax is slightly different because it is adapted for the new compilers, but the rest apply.