[原创]用Data Shape 来取关系数据库的多表记录

 

<% set conn=server.CreateObject("adodb.connection")
Conn.Open 
"Provider=MSDataShape;" & _
"Data Provider=SQLOLEDB;" & _
"Data Source=localhost;" & _
"Initial Catalog=db_dsms;" & _
"User ID=sa;" & _
"Password=SC;"
set rs=server.CreateObject("adodb.recordset")
strShape 
= "SHAPE {SELECT * FROM tb_users}" & _
" APPEND ({SELECT * FROM tb_task}" & _
" RELATE user_id to task_from) AS rsTitles"
rs.open strshape,conn,1,1
       set rs2=rs("rstitles").value

        do
 until rs.eof
        response.Write(rs(
"user_name")&"<br>")
        
do until rs2.eof
            response.Write(rs2(
"task_name")&"<br>")
            rs2.movenext
            
loop
    rs.movenext
    
loop
rs.close
rs2.close
set rs=nothing
set rs2=nothing
 
%>

 

posted on 2005-05-30 10:34  雪无止境  阅读(384)  评论(0编辑  收藏  举报