Home > Software engineering >  How the vb access MDB long binary data in the database
How the vb access MDB long binary data in the database

Time:10-05

I'm a beginner
Want to get one from the inside of the MDB database table and export long binary data read from the vb applet
(has clear long binary data file format for *. CLL)
The following is a code, run to. SaveToFile mystr, broke off adSaveCreateOverWrite
Real-time error prompt "3004", written to the file failed, brothers help analysis under the ah,,,
in distress
Private Sub Command1_Click ()

Dim conn As New ADODB. Connection
Dim the rs As New ADODB. You
Dim Str1 As String
Dim Str2 As String
Dim Str3 As String
Str1="Provider=Microsoft. Jet. The OLEDB. 4.0;"
Str2="Data Source=D: \ \ Access_db MDB file MDB;"
Str3="Jet OLEDB: Database Password="
Dim mystr As String
Dim the MST As New ADODB. Stream

Conn. Open Str1 & amp; Str2 & amp; Str3
S="select * from Z_Bd"
Rs. The Open S, conn, 3, 3

The Do While Not rs. EOF=True
DoEvents
Mystr=App. Path & amp; "\ " & amp; "CLL" '
With the MST
The Mode=adModeReadWrite
. Type=adTypeBinary
. Open
. Write rs. Fields (" TableBd ")
. SaveToFile mystr, adSaveCreateOverWrite
End With
The MST. Close
Rs. MoveNext
Loop

Rs. Close
Conn. Close
End Sub

CodePudding user response:

Check whether the field is for ole type
Check whether ado version is 2.5 and above

CodePudding user response:

Why use the ADODB library Stream to write? Not directly like this?
 
'...
Dim byt () As Byte
Byt=rs (" TableBd "). GetChunk (rs (" TableBd "). ActualSize)
Open "C: \ results. CLL" for binary As # 1
Put # 1, byt
Close # 1

Moreover you read the contents of the table all the code, read a article, write a, good tired oh, is a must to be like this?
And the key is the DoEvents, be sure to take out, or you head a haven't finished writing, you write the content of the article 2 followed came in (written or time), so it's easy to go wrong!
  • Related