sql="select * from table1 where id=null" //因为返回null的记录集 rs.open sql,conn,1,3 if rs.eof then rs.addnew rs("1")=1 rs.update else rs("1")=1 //永远也不会执行,达不到更新的目的 rs.update end if rs.close /////////////////////////////////////// 试试: Dim id id=你的id sql="select * from table1 where id='"&id&"'" rs.open sql,conn,1,3 if not rs.eof then rs("1")=1 else rs.addnew rs("1")=1 end if rs.update rs.close
1. sql="select * from table1 where id=null" --如果是要判断为null的集合,那么要where id is null2.如果返回null集合,asp认为是有一笔纪录!这个和什么都没有(0 rows affected)是不一样的 所有id为null的纪录,肯定是可以找出来的3.rs.open sql,conn,1,3,第3个参数等于1就是AdOpenKeyset在多人共用数据库时,若以AdOpenKeyset 模式打开数据表,则无法看到其他人新增的数据记录(除非重新启动)。你的这个参数在你这种更新模式下,似乎不是太好,最好设置为4.如果字段名为数字,要加上[]号,就是rs("[1]")=1 你也可以直接用数字来表明第几个字段,加入 rs("[1]")是第2个,你就rs(2)=1即可!不过我不推荐用,因为如果你插入了新的字段,那么这个序号就不对,那么就要修改代码,我们用rs("字段名")比较好,一般,我们不会轻易修改字段名,对不对!
rs.open sql,conn,1,3
if rs.eof then
rs.addnew
rs("1")=1
rs.update
else
rs("1")=1 //永远也不会执行,达不到更新的目的
rs.update
end if
rs.close
///////////////////////////////////////
试试:
Dim id
id=你的id
sql="select * from table1 where id='"&id&"'"
rs.open sql,conn,1,3
if not rs.eof then
rs("1")=1
else
rs.addnew
rs("1")=1
end if
rs.update
rs.close
把rs("1")改为rs("[1}")
--如果是要判断为null的集合,那么要where id is null2.如果返回null集合,asp认为是有一笔纪录!这个和什么都没有(0 rows affected)是不一样的
所有id为null的纪录,肯定是可以找出来的3.rs.open sql,conn,1,3,第3个参数等于1就是AdOpenKeyset在多人共用数据库时,若以AdOpenKeyset 模式打开数据表,则无法看到其他人新增的数据记录(除非重新启动)。你的这个参数在你这种更新模式下,似乎不是太好,最好设置为4.如果字段名为数字,要加上[]号,就是rs("[1]")=1
你也可以直接用数字来表明第几个字段,加入
rs("[1]")是第2个,你就rs(2)=1即可!不过我不推荐用,因为如果你插入了新的字段,那么这个序号就不对,那么就要修改代码,我们用rs("字段名")比较好,一般,我们不会轻易修改字段名,对不对!
要用 is null