返回UPDATE SQL语句所影响的行数的方法

作者:不详 来源: 日期:2002-5-31
 用如下方法可以直接得到影响的行数: 

<% 
dim conn 
dim sql 
dim lngrecs 

sql="update table1 set field1=`good`" 
set conn=server. 
createobject("adodb.connection") 
conn.open dsn 
conn.execute sql,lngrecs 
conn.close:set conn=nothing 

response.write lngrecs 
%> 

用存储过程也有同样的功能: 
<% 
dim cmd 
dim lngrecs 
dim sql 

sql="update table1 set field1=`good`" 
set cmd=server.createobject("adodb.command") 
with cmd 
.activeconnection=dsn 
.commandtype=adcmdstoredproc 
.commandtext=sql 
.execute lngrecs,,adexecutenorecords 
end with 
set cmd.activeconnection.nothing 
set cmd=nothing 

response.write lngrecs 
%>
相关文章