当前位置: 移动技术网 > IT编程>开发语言>.net > ASP判断数据库值是否为空的通用函数

ASP判断数据库值是否为空的通用函数

2019年01月18日  | 移动技术网IT编程  | 我要评论

宋岳庭怎么死的,杨元庆离婚,交通违章代码

由于各种字段属性不同,判断字段是否为空的方法也各异.

下面是一个通用函数,免去了还要看字段类型之苦.

check a variable isnt "empty"
function isblank(byref tempvar)
by default, assume its not blank
isblank = false
now check by variable type
select case vartype(tempvar)
empty & null
case 0, 1
isblank = true
string
case 8
if len(tempvar) = 0 then
isblank = true
end if
object
case 9
tmptype = typename(tempvar)
if (tmptype = "nothing") or (tmptype = "empty") then
isblank = true
end if
array
case 8192, 8204, 8209
does it have at least one element?
if ubound(tempvar) = -1 then
isblank = true
end if
end select
end function

应用实例:

if isblank(rs("upic")) then
  upicurl="/images/nonepic.jpg"
 else
  upicurl=rs("upic")
 end if

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网