Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > IT 认证 > 其它认证 > asp 向 sql server 2k 要数据
【标  题】:asp 向 sql server 2k 要数据
【关键字】:asp,sql,server,2k
【来  源】:http://blog.chinaunix.net/article.php?articleId=37092&blogId=3534

asp 向 sql server 2k 要数据

Your Ad Here

本地服务器数据库 testdb

表 title1

name       urlname              id        
---------- -------------------- ---------- 
a         ./x.asp          1         
b       ./a.asp          2         
c       ./j.asp           3         
d       ./p.asp           4         
e       ./n.asp           5         
f       ./k.asp           6         g       ./lx.asp           7   

表 title2

name                                               urlname                                            id         id2       
-------------------------------------------------- -------------------------------------------------- ---------- ---------- 
b1                                               ./g.asp                                         2          21        
b2                                               ./h.asp                                         2          22        
b3                                              ./y.asp                                         2          23        
b4                                              ./l.asp                                         2          24        
c1                                             ./h.asp                                        3          31        
c2                                              ./s.asp                                         3          32        
c3                                       ./x.asp                                        3          33        
d1                                            ./z.asp                                       4          41        
d2                                         ./k.asp                                       4          42        
d3                                           ./g.asp                                       4          43        
d4                                         ./c.asp                                       4          44        
d5                                        ./x.asp                                  4          45                    

asp  连接文件

<%
set cn = Server.CreateObject("ADODB.Connection")
cnstr="Provider=SQLOLEDB.1;Data Source=(local);User ID=sa;Password=;Database=testdb;"
on error resume next
cn.open cnstr
if err.number <> 0 then
 response.redirect("err.asp?xx=不能连接数据库,可能是WEB数据库服务器没有启动")
end if
%>

asp 数据需求文件

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<!--#include file="conn.asp"-->
<% 
set rs=server.CreateObject("adodb.recordset")
rs.open"select * from title1",cn,1,1
%>
<style type="text/css">
<!--
body {
 margin-left: 0px;
 margin-top: 0px;
 margin-right: 0px;
 margin-bottom: 0px;
}
-->
</style>
</head>

<body>
<table width="100%" border="0">
  <tr>
    <th align="left" bgcolor="#666699" scope="col">
 
 <%
      do while not rs.eof 
     %>
  <a href="<%=rs("urlname")%>" target="_self"><%= rs("name") %></a><br>
   
  <% idStr = rs("id")
  set rs1=server.CreateObject("adodb.recordset")
  rs1.open "SELECT * FROM title2 WHERE id = '"&idStr&"'",cn,1,1
  if rs1<>NaN then
 %>
   <%
      do while not rs1.eof 
      %>
   <a href="<%=rs1("urlname")%>" target="_self"><%= rs1("name") %></a><br>
 
   <%
   rs1.movenext
   loop
  %>
   <%
   rs1.close
  %>
  <% end if %>
 
   
  <%
  rs.movenext
  loop
 %>
 <% rs.close %>
 <% cn.close %> </th>
  </tr>
</table>
</body>
</html>

结果


b
b1 
b2
b3
b4 
c
c1 
c2 
c3 

d1 
d2 
d3 
d4 
d5 

f
g

asp ms sql server 新闻内容字段段落格式处理:【上一篇】
FTP命令大全及其应用:【下一篇】
【相关文章】
  • asp ms sql server 新闻内容字段段落格式处理
  • T-SQL 练习
  • T-SQL 练习 2
  • 70-215:安装、配置和管理 Microsoft Windows 2000 Server
  • 70-228:安装、配置和管理 SQL Server 2000
  • 70-229:用 Microsoft SQL Server 2000 Enterprise Edit
  • 在Windows 2003/XP with SQL Server下部署Snort入侵检测系统
  • Mysql 4.x
  • GoodTech Telnet Server 5.x
  • 菜鸟学习SQL注射<转>
  • 【随机文章】
  • 在关闭对话框中显示睡眠选项
  • 一粒种子
  • 三大银行网页存在漏洞 用户账号可轻易骗取
  • 《魔兽世界》教你做人的11条哲理
  • GRANT用法简介
  • 超长数的加法
  • HDR光照范例
  • syscolumns
  • SSH Secure Shell 3.0.0 Vulnerability Scanner
  • vs.net2005 beta2与wse2.0
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.