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

ASP
看人家用使用InstallShield制作ASP安装程序(5)
看人家用使用InstallShield制作ASP安装程序(4)
看人家用使用InstallShield制作ASP安装程序(3)
看人家用使用InstallShield制作ASP安装程序(2)
看人家用使用InstallShield制作ASP安装程序(1)
取得浏览者的离开时间
base64编码、解码函数
动态显示图片的函数(显示广告条)
发送带附件的HTML格式邮件例程可以带附件
一种在父窗口中得知window.open()出的子窗口关闭事件的方法
一个老个写的无组件上传
避免asp的SQL的执行效率低
树型结构在ASP中的简单解决
无需数据库循环的无级分类代码
检查字符串strSource是否为big或big5码
有关重复记录的删除(SQL SERVER)
WINDOWS2000服务器账号登陆身份验证
使用VC++6.0制作ASP服务器控件简介
利用sql的存储过程实现dos命令的asp程序
WSH 直接将查询数据结果生成 EXCEL 表

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 179 ::
收藏到网摘: 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