A streamlined use of AdoDb.Stream reads and writes the "big field" VB code!

zhaozj2021-02-08  302

'A streamlined code to read and write "big field" code, use Adodb.Stream

'Objects: Form1, Picture1

'Reference Microsoft ActiveX Data Objects 2.5 Libary

'Or Microsoft ActiveX Data Objects 2.6 Libary

Dim TempFileName As String

TempFileName = app.path & "/tempfile.tmp"

DIM adoconnection as new adodb.connection

Dim AdorecordSet As New Adodb.Recordset

Adoconnection.open "provider = microsoft.jet.Oledb.3.51; Persist security info = false; data source =" & app.path & "/mmmmxdb97.mdb"

AdoCordSet.open "Select * from BMP", Adoconnection, AdopenkeySet, AdlockOptimistic ', Adcmdtable

Debug.print adorecordSet.fields (1) .type 'big field

AdorecordSet.AddNew

Dim AdoStream as new adodo.stream

AdoStream.Type = adtypebinary

AdoStream.open

AdoStream.LoadFromfile Commondialog1.FileName

'Write binary files to big fields:

AdorecordSet.fields.Item (1) .appendchunk adoStream.read

'=================================

'Read binary data from big fields:

AdoStream.write adorecordset.fields.Item (1) .Getchunk (adorecordset.fields.Item (1) .actualsize)

AdoStream.savetofile TempFileName, IIF (Len (Trim (Trim (TempFileName, VBhidden))> 0, AdsaveCreateOverWrite, Adsavecreatenotexist)

Picture1.autosize = True

Picture1.Picture = loadingPicture (TempFileName)

转载请注明原文地址:https://www.9cbs.com/read-1101.html

New Post(0)