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

一个判断语句

a309223515 发布于 2011-04-11 09:15, 543 次点击
请问各位大侠这个判断写错了吗?不论De_name是否为空他为什么一直显示的是下拉列表呢?

De_name  文本   存人名


   sub showDe_name()
          set rs=server.createobject("ADODB.Recordset")
          sql="select * from [BJ_Business] "         
          rs.open sql,conn,1,1
          if De_name="" then
          response.Write "<form name=""form1"" method=""post"" action="""">"
          response.write "<label>"         
          set rs_C=server.createobject("ADODB.Recordset")
          sql2="select * from [CRS] where SmallClassID=2"
          rs_C.open sql2,conn,1,1
          response.Write "<select name=""Cid"" id=""Cid"">"
          do while not rs_C.eof
          response.Write "<option value=""&rs_C(Cid)&"">"&rs_C("Cname")&"</option>"
          rs_C.movenext
          loop
          rs_C.close
          'set rs_C=nothing         
          response.Write "</select>"
          response.Write "</label>"
          response.write "<label>"
          response.Write "<input type=""submit"" name=""button"" id=""button"" value=""确认"">"
          response.write "</label>"
          response.write "</form>"
          else              
          response.Write rs("De_name")
          rs.close
          set rs=nothing
          end if
    end sub

7 回复
#2
dzt00012011-04-11 09:19
De_name这个变量你是怎么定义的?等于什么?
#3
a3092235152011-04-11 09:44
谢谢板主在第一时间回复我
De_name是我自己定义的,他只是数据库里的一个字段(没有任何值从其它页面传过来)
我先打开数据再读取他,如果他为空则显示这个下拉列表,不为空则读出他的内容
#4
dzt00012011-04-11 10:16
首先声明本人不是版主。
那没看到你对De_name赋值,你是不是要De_name=rs("De_name")
#5
a3092235152011-04-11 10:35
回复 4楼 dzt0001

呵呵,每次有问题总是你第一个站出来,我认为你是


现在我在改,问题也不断在变
我最终要实现的是
De_name这个字段如果为空则显示一个下拉列表,不为空就读出他里面的字段
你说应该怎么写啊,或者说我的思路一开始就是错的?
#6
dzt00012011-04-11 13:59
你在if De_name="" then这句前面加De_name=rs("De_name")不就行了,或者直接写if rs("De_name")="" then

#7
a3092235152011-04-11 15:48
回复 6楼 dzt0001
呵呵,大哥你说的两种方法都没错,我之前也试过的,但在这里好像根本不适用
头都大了哦
#8
chinatao2011-04-15 14:44
继续努力 dzt0001是个给力的专家
1