WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADO DAO
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

ADO Stream to Binary Buffer

 Keywords: ADO ADODB Stream to Binary Buffer ADODB.Recordset BinaryAllocArray

dbPath = 'D:\temp\Data\sample.mdb'
myConn = ObjectOpen('ADODB.Connection')
cConn = "Provider=MicroSoft.Jet.OLEDB.4.0; Data Source=":dbPath
myConn.Open(cConn)

SQLText="SELECT rec_num, iimage as blobject from images where rec_num = '9780005080788';"
myRS=CreateObject("ADODB.Recordset")
myRS=myConn.Execute(SQLText)
myRS.MoveFirst()
While myRS.EOF == @FALSE
   isbn = myRS.Fields("rec_num").Value ;Get isbn
   fname = "images\":isbn:"_test.jpg" ;define filename
   AStream = CreateObject("ADODB.Stream")
   AStream.Type = 1 ; binary
   AStream.Open()
   AStream.Write( myRS.Collect("blobject") ) ;Write data to stream object
   btxt = AStream.Read(-1)      ; Read data from stream
   AStream.position = 0  ;Position to the beginning of the stream
   BinBuf = BinaryAllocArray(btxt)
   BinaryWrite(BinBuf, fname)
   BinaryFree(BinBuf)
   AStream.close()
   AStream=0
   myRS.MoveNext()
EndWhile
myRS.Close()

Article ID:   W18034
Filename:   ADO Stream to Binary Buffer.txt
File Created: 2011:11:01:11:39:56
Last Updated: 2011:11:01:11:39:56