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

这个sql语句怎么运行不了。

xinzhi9090 发布于 2010-07-17 12:57, 715 次点击
<!--#include file="conn.asp"-->
<%
    Set rs = server.CreateObject("adodb.recordset")
    sql = "select * from b "
    rs.Open sql, conn, 1, 3
    do while not rs.eof
    zhuye=rs("zhuye")
    dianhua=rs("dh")
    Set rs1 = server.CreateObject("adodb.recordset")
    sql1="select * from a where dh='"&rs("dh") and zhuye="" &"'"
    rs1.Open sql1, conn, 1, 3
    do while not rs1.eof
    rs1("zhuye") = zhuye
    rs1.update
    rs1.movenext
loop
rs1.close
    rs.movenext
loop
rs.close
set rs=nothing

response.write "更新完毕"  
   
    %>


原先这句是可以正常运行的:sql1="select * from a where dh='"&rs("dh") &"'"

后面加个判断语句,要是 zhuye字段为空,才更新 : sql1="select * from a where dh='"&rs("dh") and zhuye="" &"'"

但是这个语句有问题:Microsoft VBScript 运行时错误 (0x800A000D)
类型不匹配: '[string: "select * from a wher"]'
/albb/albb.asp, 第 10 行


到底该怎么写呢。。。。。请教下大家


先~谢谢~了~~
7 回复
#2
xinzhi90902010-07-17 16:09
顶~~
#3
chengstone2010-07-17 16:19
sql1="select * from a where dh='"&rs("dh") &"'  and zhuye="""
#4
gupiao1752010-07-17 16:31
如果变量dianhua都是字符型数据,试试这样:
sql1="select * from where dh='"&dianhua&"' and zhuye<>null"
#5
gupiao1752010-07-17 16:32
或者sql1="select * from a where dh='"&dianhua&"' and zhuye=null"
#6
jjld2010-07-18 09:05
sql1="select * from a where dh='"&rs("dh") &"'and zhuye=null"
"
#7
魏兴耀2010-07-18 18:25
SQL里的空用null表示咯,楼上的说的是对的
#8
chengstone2010-07-19 08:10
sql1="select * from a where dh='"&rs("dh") &"'  and zhuye=''"
两个单引号和NULL是不一样的 NULL表示没有数据,即未插入数据
  单引号表示已经插入数据了,但数据是空的
1