标题:如何读取两个表!
只看楼主
xing599666
Rank: 2
等 级:论坛游民
帖 子:104
专家分:91
注 册:2005-5-17
结帖率:85%
已结贴  问题点数:20 回复次数:6 
如何读取两个表!
好久没写程式了!代码都忘了~
究竟要怎么写啊
sql="select * from A表 where Ax_ding=true order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof Then
response.write "暂无一级分类"
end if
do while not rs.eof
response.write "这是一级分类"

sql="select * from B表 where Ax_CID="&rs("ID")&" order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof Then
response.write "暂无暂无二级分类"
end if
do while not rs.eof
response.write "这是二级分类"
rs.movenext
loop
rs.close
set rs=Nothing

rs.movenext
loop
rs.close
set rs=Nothing


[ 本帖最后由 xing599666 于 2011-2-1 19:25 编辑 ]
搜索更多相关主题的帖子: sql where 如何 
2011-02-01 19:23
zmh886
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:12
帖 子:238
专家分:1305
注 册:2010-6-2
得分:0 
把后面的rs改成rs2

http://www./
2011-02-01 22:15
xing599666
Rank: 2
等 级:论坛游民
帖 子:104
专家分:91
注 册:2005-5-17
得分:0 
好像不行哦。
sql="select * from A表 where Ax_ding=true order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof Then
response.write "暂无一级分类"
end if
do while not rs.eof
response.write "这是一级分类"

sql="select * from B表 where Ax_CID="&rs("ID")&" order by id desc"
set rs2=server.createobject("adodb.recordset")
rs2.open sql,conn,1,1
if rs2.eof and rs2.bof Then
response.write "暂无暂无二级分类"
end if
do while not rs2.eof
response.write "这是二级分类"
rs2.movenext
loop
rs2.close
set rs2=Nothing

rs.movenext
loop
rs.close
set rs=Nothing
2011-02-02 01:36
xing599666
Rank: 2
等 级:论坛游民
帖 子:104
专家分:91
注 册:2005-5-17
得分:0 
标准表达式中数据类型不匹配。


[ 本帖最后由 xing599666 于 2011-2-2 01:41 编辑 ]
2011-02-02 01:37
zmh886
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:12
帖 子:238
专家分:1305
注 册:2010-6-2
得分:20 
加了个单引号试试
sql="select * from B表 where Ax_CID='"&rs("ID")&"' order by id desc"

http://www./
2011-02-02 18:01
tandezhong
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:31
专家分:118
注 册:2011-2-11
得分:0 
回复 3楼 xing599666

你是要这个效果吗..?
<%
           set re=server.CreateObject("adodb.recordset")
           sql="select ID,NewsTree,NewsConten from NewTree where NewsTree='0' order by ID Desc"
           re.open sql,Admin_b,1,3
      %>         
      <%
           do while not re.eof
           d=re("ID")
      %>      
       <dd><font style="color:#09F; font-size:14px;"><%if len(re("NewsConten"))>7 then response.Write left(re("NewsConten"),7)&".." else response.Write re("NewsConten") end if%></font>&nbsp;&nbsp;<a href="ATreeEdit.asp?Aid=<%=d%>" target="right">编辑</a>&nbsp;&nbsp;删除
        <dl>
        <%   
         set rs=server.CreateObject("adodb.recordset")
         sql_t="select ID,NewsTree,NewsConten from NewTree where NewsTree='"&d&"'"
         rs.open sql_t,Admin_b,1,3
        %>
        <%
        do while not rs.eof
        dd=rs("ID")
        %>        
         <dt><% if len(rs("NewsConten"))>7 then response.Write left(rs("NewsConten"),7)&".." else response.Write rs("NewsConten") end if%>&nbsp;&nbsp;[<a href="TreeEdit.asp?id=<%=dd%>" target="right" class="txt_01">编辑</a>]&nbsp;[<a href="javascript:Tree_de(<%=dd%>)" target="right" class="txt_01">删除</a>]</dt>
         <%   
         rs.movenext
         loop
         rs.close
         set rs=nothing
        %>         
        </dl>
        </dd>
        <%
        re.movenext
        loop
        re.close
        set re=nothing
        %>            
2011-02-11 17:13
xing599666
Rank: 2
等 级:论坛游民
帖 子:104
专家分:91
注 册:2005-5-17
得分:0 
是的
2011-02-11 17:23



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-331802-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.157761 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved