Public Sub loadpic(ByRef fld As ADODB.Fields, picpath As String)
Dim f As Integer
Dim nBlock As Long
Dim nRemain As Long
Dim i As Long
Const NumPerBlock As Long = 1024
f = FreeFile
picpath = Trim(picpath)
If picpath = "" Then
Exit Sub
End If
On Error Resume Next
err.Clear
Open picpath For Binary As f
If err.Number <> 0 Then
' fld(0).Value = Null
err.Clear
Close f
Exit Sub
End If
nBlock = LOF(f) \ NumPerBlock
nRemain = LOF(f) - nBlock * NumPerBlock
ReDim By(NumPerBlock) As Byte
For i = 1 To nBlock
Get f, , By()
fld(0).AppendChunk By()
Next
If nRemain > 0 Then
ReDim By(nRemain) As Byte
Get f, , By()
fld(0).AppendChunk By()
End If
Close f
End Sub
Dim f As Integer
Dim nBlock As Long
Dim nRemain As Long
Dim i As Long
Const NumPerBlock As Long = 1024
f = FreeFile
picpath = Trim(picpath)
If picpath = "" Then
Exit Sub
End If
On Error Resume Next
err.Clear
Open picpath For Binary As f
If err.Number <> 0 Then
' fld(0).Value = Null
err.Clear
Close f
Exit Sub
End If
nBlock = LOF(f) \ NumPerBlock
nRemain = LOF(f) - nBlock * NumPerBlock
ReDim By(NumPerBlock) As Byte
For i = 1 To nBlock
Get f, , By()
fld(0).AppendChunk By()
Next
If nRemain > 0 Then
ReDim By(nRemain) As Byte
Get f, , By()
fld(0).AppendChunk By()
End If
Close f
End Sub
SavePicture Image1.Picture, "abccba.tmp"
pic.Type = adTypeBinary
pic.Open
pic.LoadFromFile "abccba.tmp"
pic.Read rs!carpic
pic.Close
Kill "abccba.tmp"
这个简单,如何