日期:2014-05-17  浏览次数:20514 次

下面的SQL语句标准吗?
set rs=conn.execute("select url from web where url = " & domain & " or title = " & title & "")
if not rs.eof then
else
set rsin=conn.execute("insert into web(title,url) values(" & title & "," & domain & ")")
rsin.close
set rsin=Nothing
end if
rs.close
set rs=Nothing
conn.close
set conn=nothing
要怎么写占用资源最少,并且不出错。

------解决方案--------------------
title 或 domain 有'符号时上面的脚本就有错了,把一个'替换成两个''

类似replace(titl3,"'","''"),具体asp是什么函数或语法来替换就不清楚了

------解决方案--------------------
vbscript的代码,好像少了单引号,改成下面
VBScript code

set rs=conn.execute("select url from web where url = '" & domain & "' or title = '" & title & "'")
if not rs.eof then
else
set rsin=conn.execute("insert into web(title,url) values('" & title & "','" & domain & "')")
rsin.close
set rsin=Nothing
end if
rs.close
set rs=Nothing
conn.close
set conn=nothing

------解决方案--------------------
一个select 一个insert into 从SQL 的角度的都是标准的语句。

关于rs和rsin的问题,我也不懂,
------解决方案--------------------
rs应该少不了吧,那只能减少rsin的使用,
改成下面试试
VBScript code

dim strSql
if not rs.eof then
else
set strSql=strSql+" insert into web(title,url) values(" & title & "," & domain & ")")
end if
set rsin=conn.execute(strSql)
rsin.close
set rsin=Nothing