您的位置:程序门 -> vb -> 数据库(包含打印,安装,报表)



向access中存取图片的问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


向access中存取图片的问题
发表于:2007-03-07 12:42:36 楼主
public   sub   savepictodb(cn   as   adodb.connection,   table1   as   string,   field1   as   string,   file1   as   string,   id1   as   string)
on   error   goto   err_handle
dim   stm   as   adodb.stream
set   stm   =   new   adodb.stream
set   rs1   =   new   adodb.recordset
rs1.open   "select       *       from   "   &   table1   &   "   where   id   =   "   &   id1,   cn,   adopenkeyset,   adlockoptimistic

with   stm
        .type   =   adtypebinary
        .open
        .loadfromfile   file1               'dlg.filename
end   with

with   rs1
        .fields(field1)   =   stm.read
        .update
end   with
rs1.close
set   rs1   =   nothing
exit   sub
err_handle:
msgbox   (err.description)
end   sub


public   sub   getpicfromdb(cn   as   adodb.connection)
on   error   goto   hand
dim   fld   as   field
dim   strtemp           as   string
dim   stm           as   adodb.stream
set   stm   =   new   adodb.stream
'strtemp       =       "c:\temp.bmp "
set   rs1   =   new   adodb.recordset
rs1.open   "select   *   from   table1   where   id= '1 ' ",   cn,   ,   ,   adcmdtext
while   not   rs1.eof
'       strtemp       =       app.path       +       "\temp\ "       +       rs1!name       '
        with   stm
                .type   =   adtypebinary
                .open
                .write   rs1( "pic ").value
                strtemp   =   app.path   &   "\temp1\ "   &   "lihuanzhong.jpg "
                .savetofile   strtemp,   adsavecreateoverwrite
                .close
        end   with
        rs1.movenext
wend
set   stm   =   nothing
rs1.close
set   rs1   =   nothing
exit   sub
hand:
msgbox   ( "´íîó ")
end   sub


这段程序在存图片时没问题,但是在取图片生成文件时.write   rs1( "pic ").value会出错,提示“参数类型不正确,或不在可接受的范围内,或与其他参数冲突,这是什么原因怎么解决


快速检索

最新资讯
热门点击