当前位置: 首页 > 图文教程 > 网络编程 > ASP > asp程序实现伪静态的代码

ASP
如何编写适合FireFox的对话框?
关于处理GET方式提交的含有特殊字符的参数
对URL地址进行编码 优化2
在线管理数据库 类
用Asp备份与恢复SQL Server 数据库
计算两个时间之差的函数
asp实现sql的备份与恢复
SQL Server 存储过程的分页
sql 存储过程分页
邹建的分页存储过程改了一下
关于使用存储过程创建分页
SQL SERVER编写存储过程小工具
各种存储过程使用指南
SQL Server--怎样用ADO在SQL SERVER中建库,建表
几例在ASP存储过程的使用方法
用ASP+XML打造留言本
让 Asp 与 XML 交互
msxml3.dll 错误 ''800c0005''解决方案
MSXML4.0 版中的新增功能
关于ASP生成伪参数技巧

ASP 中的 asp程序实现伪静态的代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 70 ::
收藏到网摘: n/a

静态页面是蜘蛛喜欢的,会得到蜘蛛经常光顾的,以至于网站上的内容会得到搜索引擎更多的收录
这里介绍一个asp伪静态的程序实现方法
数据库是access,表名article,里面有id,title,content
config.asp连接数据库文件
< %
'功能:asp实现伪静态的例子
'网址:www.aspprogram.cn
'来源:网络

'数据库链接   
db="data.mdb"  
Set conn = Server.CreateObject("ADODB.Connection")   
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)   
conn.open connstr
    If Err Then  
        err.Clear   
        Set conn = Nothing  
        Response.Write "数据库连接出错,请检查连接字串。"  
        Response.End  
    End If
'定义新闻阅读界面的读取
Dim News_title,News_content   
Sub ReadNews()   
 set rs1=server.createobject("adodb.recordset")   
    sql1="select id,title,content from article where id="& ID   
    rs1.open sql1,conn,3,3   
    News_title=rs1("title")   
    News_content=rs1("content")   
rs1.close   
set rs1=Nothing  
End Sub 
% >

index.asp新闻列表页

< !--#include file="config.asp"-- >   
<ol>   
< %   
Set rs=server.CreateObject("adodb.recordset")   
sql="select * from Article"  
rs.open sql,conn,1,1   
do while not rs.eof   
% >   
<li><a href="http://www.aspprogram.cn/article.asp?/< %=rs("id")% >.html">< %=left(trim(rs("title")),30)% ></a></li>   
< %   
rs.movenext   
loop   
rs.close   
set rs=Nothing  
% >   
</ol>

article.asp新闻内容页
< !--#include file="config.asp"-- >   
< %   
id=request.QueryString("id")   
If id="" Then    
server_v40=Request.ServerVariables("QUERY_STRING") 
id=Int(replace(replace(server_v40,"/",""),".html",""))   
End If    
Call ReadNews()   
% >   
<div>   
标题: <b>< %= News_title% ></b><br />   
内容: < %=News_content% >   
</div>

源码见:http://www.aspprogram.cn/soft.asp?id=63