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

数据库连接问题

wfemile 发布于 2008-07-21 22:34, 940 次点击
用字符连接的地方不知道有没有问题!!请高手过目下。。十分感谢!!
function getrecordsetwithid(strtablename,intid,intopentype)
  dim strsql
  strsql="select * from " & strtablename & " where id=" & intid
  set getrecordsetwithid=getrecordset(strsql,intopentype)
end function

function isexiststringvalue(srtablename,strfield,strvalue)
  dim strsql,rs
    strsql="select count(*) as count from" & strtablename & "where" & strfield &  "='" & strvalue & "'"
    set rs=getrecordset(strsql,0)
    if rs("count").value=0 then
    isexiststringvalue=false
    else
    isexiststringvalue=true
    end if
    set rs=nothing
end function

function isexiststringvaluewithoutid(strtablename,strfield,strvalue,intid)
     dim strsql,rs
     strsql="select count(*) as count from" & strtablename &  "where" & strfield & "='" &strvalue & "'" & "and id<>" & intid
   set rs=getrecordset(strsql,0)
 if rs("count").value=0 then
   isexiststringvaluewithoutid=false
   else
  isexiststringvaluewithoutid=true
end if
end function
用字符连接的地方不知道有没有问题!!请高手过目下。。十分感谢!!
3 回复
#2
yms1232008-07-21 23:55
select count(*) as count这个as后面的别名不能是count
#3
wfemile2008-07-22 20:49
这个把列取名为count。应该没问题吧
#4
yms1232008-07-22 23:46
最好避免变量或别名使用系统关键字
1