为什么?????为什么?????帮帮我!!!!!帮帮我!!!!!RecPicture.update时出错.......错误提示为:实时错误'-2147217887(80040e21)'!!!!有分散散
调试过多少次.总是在RecPicture.update时出错.......
在win98下也是.win2000也一样.
错误提示为:
实时错误'-2147217887(80040e21)'
为什么?????为什么?????为什么?????为什么?????为什么?????为什么?????
为什么?????为什么?????为什么?????为什么?????为什么?????为什么?????
帮帮我!!!!!帮帮我!!!!!帮帮我!!!!!帮帮我!!!!!帮帮我!!!!!帮帮我!!!!!
帮帮我!!!!!帮帮我!!!!!帮帮我!!!!!帮帮我!!!!!帮帮我!!!!!帮帮我!!!!!
Function SavePicture(ByVal StrFileName As String, ByVal DBConnect As ADODB.Connection, ByVal StrTable As String, ByVal Barcode As String) As Integer
'Expression by the values returned
'0 Pictrue saved is ok
'1 Picture is not exist
'2 Size of the exist Picture is 0
'3 Unknow
'On Error GoTo OnErr
Dim i As Integer
Dim lngFileLen As Long
Dim Chunks As Integer
Dim intFile As Integer
Dim Fragment As Integer
Dim Chunk() As Byte
Dim RecPicture As New ADODB.Recordset
Dim ChunkSize As Integer
ChunkSize = 32767
If Dir(StrFileName) = "" Then
SavePicture = 1
Exit Function
End If
intFile = FreeFile
Open StrFileName For Binary Access Read As intFile
lngFileLen = LOF(intFile) ' 文件中数据长度
If lngFileLen = 0 Then
Close intFile
SavePicture = 2
Exit Function
End If
Barcode = LTrim(Trim(Barcode))
StrTable = "Select Barcode,Picture,Type From " & StrTable & " Where Barcode like '" & Barcode & "'"
RecPicture.Open StrTable, DBConnect, adOpenStatic, adLockOptimistic
If RecPicture.EOF Then
RecPicture.AddNew
RecPicture.Fields("Barcode") = Barcode
End If
i = InStrRev(StrFileName, ".")
If i <> 0 Then
RecPicture.Fields("Type") = Mid(StrFileName, i + 1)
Else
RecPicture.Fields("Type") = ""
End If
Chunks = lngFileLen \ ChunkSize
Fragment = lngFileLen Mod ChunkSize
ReDim Chunk(Fragment)
Get intFile, , Chunk()
RecPicture.Fields("Picture").AppendChunk Chunk()
ReDim Chunk(ChunkSize)
For i = 1 To Chunks
Get intFile, , Chunk()
RecPicture.Fields("Picture").AppendChunk Chunk()
Next i
Close intFile
'错误出在这...
RecPicture.Update '错误出在这...
'错误出在这...
RecPicture.Close
SavePicture = 0
Exit Function
OnErr:
SavePicture = 3
Exit Function
End Function
但是:
Get intFile, , Chunk()
RecPicture.Fields("Picture").AppendChunk Chunk()
RecPicture.Update
ReDim Chunk(ChunkSize)
For i = 1 To Chunks
Get intFile, , Chunk()
RecPicture.Fields("Picture").AppendChunk Chunk()
RecPicture.Update
Next i
这样程可以更新可以执行.不会出错.
但存入的是最后一次的.RecPicture.Fields("Picture").AppendChunk Chunk()