注册 登录
编程论坛 ASP技术论坛

求助:ASP使用REPLACE函数参数中有空值报错

a275298873 发布于 2013-10-22 12:06, 501 次点击
file        =    "small.htm"


    '
    call db_conn()
    dim tpl,info
    set tpl        =    new template
    tpl.load file
    info = tpl.result()
    dim ors,isort,bsort
    set ors = server.createobject("adodb.recordset")
    ors.open "select * from [class] where id = " & toint(request("id")),conn,1,1
    if ors.eof then call myerr("未找到相应信息...")
    info = replace(info,"{系列名称}",ors("name"))
    info = replace(info,"{摘要}",ors("mark"))
    info = replace(info,"{内容}",ors("introduce"))
    info = replace(info,"{图片}",ors("pro_picture"))
    info = replace(info,"{规格}",ors("pro_spec"))
    if len(ors("bigpicture")) > 6 then
        info = replace(info,"{下载}","<a href='doc/"&ors("bigpicture")&"' target='_blanl'><img src=images/dowsms.jpg width=105 height=25 border=0></a>")
    else
        info = replace(info,"{下载}","")
    end if
    isort = ors("isort")
    bsort = ors("sort")
    info = replace(info,"{小类}",isort)
    info = replace(info,"{大类}",bsort)
    ors.close
   
运行后报错:
Microsoft VBScript 运行时错误 错误 '800a005e'

无效使用 Null: 'replace'

其中pro_picture,pro_spec是有空值的列,请问如何解决这个错误呢,让结果是如果是空值那么就用空值替换。
1 回复
#2
hugeannex2013-10-24 11:14
在if ors.eof 中作相应处理,比如退出程序啊,或按你的意思,给info赋一空值,以防后面出错。
1