作者:刘玉锋
http://aspfans.yeah.net
前一段时间本站将首页更换为了ASP+程序,为了能让更多的朋友对asp+有更好的了解,所以特将源代码
公开,至于对代码的注释,相信大家参考现在网上的asp+语法之类的东东都能看懂,主要涉及到VB与(ADO+)
对数据库进行读取操作,此程序仅仅作为一个参考。
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ADO" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<title>ASP爱好者</title>
<STYLE type=text/css>.unnamed1 {
FONT-SIZE: 9pt
}
</STYLE>
<STYLE type=text/css>A {
COLOR: #0000ff; FONT-SIZE: 9pt; TEXT-DECORATION: none
}
A:visited {
COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
COLOR: #ff99ff; TEXT-DECORATION: underline
}
TD {
FONT-SIZE: 9pt; LINE-HEIGHT: 14pt
}
</STYLE>
<script language="vb" runat=server>
Sub Page_Load(Source As Object, E As EventArgs)
Dim DS As DataSet
Dim MyConnection As ADOConnection
Dim MyCommand As ADODataSetCommand
Dim strSql as String
'以下是数据库联结
MyConnection = New ADOConnection("Driver={Microsoft Access Driver (*.mdb)};DBQ=" & server.mappath
("XXXXX.mdb"))
strSql ="SELECT top 5 Topics.T_Message,Topics.T_Status, Topics.Forum_ID, Topics.Topic_ID,
Topics.T_subject,Topics.T_Mail, Topics.T_Originator, Topics.T_Replies,
Topics.T_Last_Post,forum.Forum_ID,forum.F_Name "
strSql = strSql & "FROM Topics,forum where Topics.Forum_ID=forum.Forum_ID "
strSql = strSql & " order by Topics.T_Last_Post DESC"
MyCommand = New ADODataSetCommand(strSql, myConnection)
DS = new DataSet()
MyCommand.FillDataSet(DS, "Topics1")
dlwenzhang.DataSource = DS.Tables("Topics1").DefaultView
dlwenzhang.DataBind()
MyConnection = New ADOConnection("Driver={Microsoft Access Driver (*.mdb)};DBQ=" & server.mappath
("XXXXX.mdb"))
strSql ="SELECT top 5 * FROM links,cats where links.catid=cats.catid order by links.linkid DESC"
MyCommand = New ADODataSetCommand(strSql, myConnection)
DS = new DataSet()
MyCommand.FillDataSet(DS, "Topics2")
daima.DataSource = DS.Tables("Topics2").DefaultView
daima.DataBind()
MyConnection = New ADOConnection("Driver={Microsoft Access Driver (*.mdb)};DBQ=" & server.mappath
("XXXXX.mdb"))
strSql ="SELECT top 5 * FROM links,cats where links.catid=cats.catid order by links.linkid DESC"
MyCommand = New ADODataSetCommand(strSql, myConnection)
DS = new DataSet()
MyCommand.FillDataSet(DS, "Topics3")
zujian.DataSource = DS.Tables("Topics3").DefaultView
zujian.DataBind()
End Sub
</script>
</head>
<body>
<table border="0" width="100%" bordercolor="#008080" bordercolorlight="#C0C0C0"
bordercolordark="#FFFFFF">
<tr>
<td><img src=http://www.163design.net/a/y/"image/aspfans.gif" width="400" height="60" alt="aspfans.gif (12099 bytes)"></td>
<td width="50%" valign="middle"><a href="http://www.21ic.com" target="_blank"><img src=http://www.163design.net/a/y/"468x60-21ITT2.gif"
width="350" height="50" alt="中国电子网" border=0></a></td>
</tr>
<tr>
<td width="100%" bgcolor="#C0C0C0" colspan="2"><font color="#FFFFFF"><a href="default.asp"
>本站首页</a> - <a href="info/Default.asp"
>新闻&l