外星人大战地球:asp问题sql

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 17:09:47
set rs=server.CreateObject("adodb.recordset")
sql="select szcs from gs where szcs=''order by adddate"
rs.open sql,conn,2,3
do while not rs.eof
rs("szcs")="上海"
rs.update
rs.movenext
if rs.eof then exit do
loop
rs.close
conn.close
set rs=nothing
set conn=nothing
运行没有错误但为什么改不了数据,我是想把szcs字段为空的全不该为上海为什么不行啊??
=null
应该是is null吧
我试试

多简单:

sql="update gs set szcs='上海' where szcs is null or szcs=''"
conn.execute sql

set rs=server.CreateObject("adodb.recordset")
sql="select szcs from gs where szcs IS NULL order by adddate"
rs.open sql,conn,2,3
do while not rs.eof
rs("szcs")="上海"
rs.update
rs.movenext
if rs.eof then exit do
loop
rs.close
conn.close
set rs=nothing
set conn=nothing

你说的"我是想把szcs字段为空的全不该为上海"这句话什么意思啊?
你到底是想把szcs不为空的改为上海,还是szcs为空的改为上海?

如果是szcs为空改为上海应该是:
sql="select szcs from gs where szcs is null order by adddate"
rs.open sql,conn,2,3
do while not rs.eof
rs("szcs")="上海"
rs.update
rs.movenext
if rs.eof then exit do
loop

如果是szcs不为空改为上海应该是:
sql="select szcs from gs where szcs is not null order by adddate"
rs.open sql,conn,2,3
do while not rs.eof
rs("szcs")="上海"
rs.update
rs.movenext
if rs.eof then exit do
loop

不用这么麻烦,一句话搞定的事。
conn.execute("update gs set szcs='上海' where szcs id null")

sql="select szcs from gs where szcs=null order by adddate"

这样试一试