如何判断SQL2005里的图片是值是空的?

yz353535 2010-10-08 02:15:38
???
...全文
33 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jhone99 2010-10-08
  • 打赏
  • 举报
回复
const blocksize = 8192
public sub savetodb(byref fld as adodb.field, diskfile as string)
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 diskfile for binary access read as sourcefile '打开文件
filelength = lof(sourcefile) '得到文件长度
if filelength = 0 then '判断文件是否存在
close sourcefile
msgbox diskfile & "无 内 容 或 不 存 在 !"
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() '写入fld
next i
redim bytedata(leftover) '重新定义数据块的大小
get sourcefile, , bytedata() '读到内存块中
fld.appendchunk bytedata() '写入fld
close sourcefile '关闭源文件
end if
end sub
public sub readfromdb(byref fld as adodb.field, diskfile as string)
dim bytedata() as byte '定义数据块数组
dim numblocks as long '定义数据块个数
dim filelength as long '标识文件长度
dim leftover as long '定义剩余字节长度
dim loffset as long
dim sourcefile as long '定义自由文件号
dim i as long '定义循环变量
sourcefile = freefile '提供一个尚未使用的文件号
open diskfile for binary access write as sourcefile '打开文件
filelength = fld.actualsize '得到字段的实际长度
if filelength = 0 then '判断文件是否存在

close sourcefile
' msgbox diskfile & "无 内 容 或 不 存 在 !"
exit sub
else
numblocks = filelength \ blocksize '得到数据块的个数
leftover = filelength mod blocksize '得到剩余字节数
'fld.value = null
redim bytedata(leftover) '重新定义数据块的大小
bytedata() = fld.getchunk(leftover)
put sourcefile, , bytedata()
loffset = leftover
for i = 1 to numblocks
redim bytedata(blocksize) '重新定义数据块的大小
bytedata() = fld.getchunk(blocksize) '从数据库中读出一数据块到内存中
put sourcefile, , bytedata() '从内存块写入文件中
loffset = loffset + blocksize
txtbytecount = loffset
next i
close sourcefile '关闭源文件
end if

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧