Theos PowerBasic Museum 2017

Archive => Discussion - Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Topic started by: Bob Mechler on July 27, 2009, 04:28:46 AM

Title: adofield_getchunk use question
Post by: Bob Mechler on July 27, 2009, 04:28:46 AM
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

Title: Re: adofield_getchunk use question
Post by: Bob Mechler on July 27, 2009, 05:04:28 AM
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
Title: Re: adofield_getchunk use question
Post by: José Roca on July 27, 2009, 05:44:51 AM
 
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.