日期:2014-05-16  浏览次数:20943 次

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

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是有空值的列,请问如何解决这个错误呢,让结果是如果是空值那么就用空值替换。

------解决方案--------------------
if isnull(ors("pro_picture")) then
    info = replace(info,"{图片}","")
else
    info = replace(info,"{图片}",ors("pro_picture"))
end if

再试试!