Binary values

<< Click to Display Table of Contents >>

Navigation:  Getting Started >

Binary values

Previous pageReturn to chapter overviewNext page

Description

 

This release of Vo2Ado has limited support for Image values.

We have implemented the following support:

 

Both AdoField:Value and AdoRecordSet:Collect return Image values in the form of an AdoLongBinary object, and also expect a AdoLongBinary values as argument when assigning a new values to a field of type Image.

 

The AdoServer class treats Image values as Memo-type fields, and returns the contents of Image fields (through the Fieldget() method) as strings.

 

When assigning a new value to a Image field (through the FieldPut() method), you must give this string value as an argument. Internally this string is translated back into a AdoLongBinary object.

 

 

Example1: Reading binary data

 

FUNCTION Start()

LOCAL cConn AS STRING

LOCAL oRs         AS AdoRecordSet

LOCAL oFld         AS AdoField

LOCAL cPict AS STRING

LOCAL oPict AS AdoLongBinary

cConn := "Provider=SQLOleDB;Data Source=(local);Initial 

Catalog=Northwind;User Id=sa;Password=;"

oRs := AdoRecordSet{}

oRs:Open("Categories",cConn,AdOpenStatic,AdLockOptimistic, adCmdTable)

 

oFld := oRs:Fields["Picture"]

 

// Method 1: Read whole contents In one go (only of size is Not too large)

oPict := oFld:Value

cPict :=  oPict:Value

? SLen(cPict)

MemoWrit("D:\PICT1.DAT", cPict)

 

// Method 2: Get In chunks

oPict := oFld:GetChunk(1000)

cPict := ""

DO WHILE TRUE

   cPict += oPict:Value

   ? SLen(cPict)

   IF SLen(oPict:Value) < 1000

      EXIT

   ENDIF

   oPict := oFld:GetChunk(1000)

ENDDO

MemoWrit("D:\PICT2.DAT", cPict)

wait

 

Example 2: Writing binary data using Value assign

 

oRs:Open("Categories",cConn,AdOpenStatic,AdLockOptimistic, adCmdTable)

oFld         := oRs:Fields["Picture"]

cPict := MemoRead("D:\PICT3.BMP")

oPict := AdoLongBinary{cPict}

oFld:Value := oPict

oRs:Update(NIL,NIL)

 

See Also

AdoLongBinary