dim bit() as byte
后加
ReDim Bit(Ado.Recordset.Fields("pic").ActualSize- 1)
试试
解决方案 »
- 如何判断listview 或者treeview 有没有item被选中
- 救命啊!我跪下了,要不帮忙今晚要通宵了!关于SQL的,今者有分
- 做个QQ聊天室自动聊天程序中碰到的问题,请教高手!
- 大哥大姐,请告诉我;这样把text1的内容和ado数据库表中的数据绑定起来
- 关于还原数据库
- 如何把.bmp图片转为ico图片?
- 发布新软件——《我从来不怕背单词》——帮您打造自己的生词本!!进者有分!!
- 无偿提供printer对象所有属性,需要的进来看吧!
- 谁有EAN13条形码字体?
- 请问大家在数据备份时,压缩是怎么做的?
- 怎样得到局屿网上所有的计算机名,我想给班里写个局屿网聊天程序,原想用DX8,但DX8好想建立的连接都是C/S模式的。如果能得到机器名就可以用WINSOCK写了
- 问题简单分数多多!
改成
dim bit(Ado.Recordset.Fields("pic").ActualSize) as byte
好象不能这样定义吧!
Dim nFileHandle As String
Dim nFileLen As Long
Dim abFile() As Byte, nBlocks As Long
Dim nLoopno As Long
If Dir(sFileName) <> "" Then
nFileLen = FileLen(sFileName)
If nFileLen > 0 Then
nBlocks = (nFileLen - nFileLen Mod MAX_BLOCK_SIZE) / MAX_BLOCK_SIZE
nFileHandle = FreeFile
Open sFileName For Binary As nFileHandle
If nBlocks > 0 Then
ReDim abFile(0 To MAX_BLOCK_SIZE - 1)
For nLoopno = 1 To nBlocks
Get nFileHandle, MAX_BLOCK_SIZE * (nLoopno - 1) + 1, abFile
rsRecordset.Fields(sField).AppendChunk abFile
Next nLoopno
End If
If nFileLen Mod MAX_BLOCK_SIZE > 0 Then
ReDim abFile(0 To nFileLen - nBlocks * MAX_BLOCK_SIZE - 1)
Get nFileHandle, nBlocks * MAX_BLOCK_SIZE + 1, abFile
rsRecordset.Fields(sField).AppendChunk abFile
End If
Close nFileHandle
End If
End If
End SubPublic Sub GetFileFromDB(rsRecordset As ADODB.Recordset, sField As String, sFileName As String)
Dim nFileHandle As String
Dim nFileLen As Long
Dim abFile() As Byte, nBlocks As Long
Dim nLoopno As Long
If Dir(sFileName) <> "" Then
Kill sFileName
End If
nFileHandle = FreeFile
Open sFileName For Binary As nFileHandle
nFileLen = rsRecordset.Fields(sField).ActualSize
nBlocks = (nFileLen - nFileLen Mod MAX_BLOCK_SIZE) / MAX_BLOCK_SIZE
If nBlocks > 0 Then
ReDim abFile(0 To MAX_BLOCK_SIZE - 1)
For nLoopno = 1 To nBlocks
abFile = rsRecordset.Fields(sField).GetChunk(MAX_BLOCK_SIZE)
Put nFileHandle, MAX_BLOCK_SIZE * (nLoopno - 1) + 1, abFile
Next nLoopno
End If
If nFileLen Mod MAX_BLOCK_SIZE > 0 Then
ReDim abFile(0 To nFileLen - nBlocks * MAX_BLOCK_SIZE - 1)
abFile = rsRecordset.Fields(sField).GetChunk(UBound(abFile) + 1)
Put nFileHandle, nBlocks * MAX_BLOCK_SIZE + 1, abFile
End If
Close nFileHandle
End Sub
sFiled -- 图片存放在表中的字段名
sFileName -- 文件名
你说得对,不可以直接这样定义。foolishtiger(吴文智)的方法应该可以。
(这两个函数我试过在VB6+SP5+MDB是没有问题的)