VB queries the BLOB Type field in Oracle and displays the picture in the Blob as a stream on the image

Source: Internet
Author: User

Original digest from: http://heisetoufa.iteye.com/blog/504068
'Module CodePrivate Declare FunctionCreateStreamOnHGlobalLib "ole32"(ByValHglobal as Long,ByValFdeleteonrelease as Long, ppstm asAny) as LongPrivate Declare FunctionOleLoadPictureLib "Olepro32"(PStream asAny,ByValLsize as Long,ByValFrunmode as Long, riid asAny, ppvobj asAny) as LongPrivate Declare FunctionCLSIDFromStringLib "ole32"(ByValLpsz asAny, pCLSID asAny) as LongPrivate Declare FunctionGlobalAllocLib "kernel32"(ByValUflags as Long,ByValDwbytes as Long) as LongPrivate Declare FunctionGlobalLockLib "kernel32"(ByValHmem as Long) as LongPrivate Declare FunctionGlobalUnlockLib "kernel32"(ByValHmem as Long) as LongPrivate Declare SubMovememoryLib "kernel32" Alias "RtlMoveMemory"(PDest asAny, Psource asAny,ByValDwlength as Long)Private Declare FunctionGlobalFreeLib "kernel32"(ByValHmem as Long) as Long PublicType GUID'bytes (+ bits)'dwData1 as Long ' 4 bytes'wData2 as Integer ' 2 bytes'wData3 as Integer ' 2 bytesABDATA4 (7) as Byte '8 bytes, zero basedEndType Public FunctionPicturefrombytestream (B () as Byte) asIPictureDimHmem as Long    DimLpmem as Long    DimLowerbound as Long    DimByteCount as Long    DimIid_ipicture asGUIDDimIstm asstdole. IUnknown lowerbound=LBound(B) ByteCount=UBound(B)-lowerbound +1Hmem= GlobalAlloc (&H2, ByteCount)IfHmem <>0  ThenLpmem=GlobalLock (HMEM)IfLpmem <>0  ThenmovememoryByValLpmem, B (lowerbound), ByteCount globalunlock HmemIfCreateStreamOnHGlobal (Hmem,1, istm) =0  Then                                IfCLSIDFromString (STRPTR ("{7bf80980-bf32-101a-8bbb-00aa00300cab}"), iid_ipicture) =0  ThenOleLoadPictureByValObjPtr (istm), ByteCount,0, Iid_ipicture, PicturefrombytestreamEnd If                            End If                    End If            End If    End Function
 Public SubCombo1_click ()DimAdocnn asADODB. ConnectionDimRstora asADODB. RecordsetDimIntI as Integer         SetADOCNN =NewADODB. ConnectionSetRstora =NewADODB. Recordset adocnn.connectionstring="provider=oraoledb.oracle; User Id=dzjc;password=zlkj;data source=dzjc_2005;" 'read BLOB fields to use Provider=oraoledb.oracleadocnn.cursorlocation=adUseClient adocnn.open rstora.cursorlocation=adUseClient rstora.activeconnection=adocnn Rstora.open"SELECT ZP from dzjc.dzjc_wfzp WHERE xh = ' 5 '"              'Set Image1.datasource = Rstora              SetImage1.picture = Picturefrombytestream (Rstora.fields ("ZP"). Value)End Sub
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.