VB+SQL 图片存取vb 代码 VB 窗体界面如下: 1
把图片写入到 Field 中函数代码: Private Sub picsavetodb(ByRef fld As ADODB
Field, diskfile As String) Const blocksize = 4096 Dim bytedata() As Byte Dim numblocks As Long Dim filelength As Long Dim leftover As Long Dim sourcefile As Long Dim i As Long sourcefile = FreeFile Open Trim(CommonDialog1
filename) For Binary Access Read As sourcefile filelength = LOF(sourcefile) If filelength = 0 Then Close sourcefile MsgBox Trim(CommonDialog1
filename) & "无内容或不存在
" Else numblocks = filelength \ blocksize leftover = filelength Mod blocksize fld
Value = Null ReDim bytedata(blocksize) For i = 1 To numblocks Get sourcefile, , bytedata() fld
AppendChunk bytedata() Next ReDim bytedata(leftover) Get sourcefile, , bytedata() fld
AppendChunk bytedata() Close sourcefile End If End Sub 2