一個功能完善的專欄管理的程式->這是asp.net的第二個應用(五)
/*
豆腐製作,都是精品
http://www.asp888.net 豆腐技術站
如轉載,請保留完整著作權資訊
*/
好了,截止到這裡,我們基本上可以說是 公德圓滿了!大家可以休息休息了,我們在本章中所講的內容就是做一個 專欄管理的 首頁,首頁應該包括 所有的欄目類別,最近的10篇文章和最熱門的10篇文章我們現在來看看這個本來第一個寫的aspx檔案:default.aspx
<!--#include file="func.aspx"-->
<script language=vb runat=server>
sub WriteLanmuClass()
dim conn as SQLConnection
conn=getConn()
dim sqlCmd as SqlCommand
dim strSQL as string
dim sRead as SQLDataReader
strSQL="select * from lanmuclass"
sqlCmd=new sqlCommand(strSQL,conn)
sqlCmd.ActiveConnection.open()
sqlCmd.execute(sRead)
dim i as integer
response.write("<table border=1 width=100%><tr><td>")
while(sRead.Read())
response.write("<a href=showarticle.aspx?classid=" & sRead("classid") & ">" & sRead("classname") & "</a>(<font color=red>" & GetClassNum(cStr(sRead("classid"))) & "</font>)")
end while
response.write("</td></tr></table>")
end sub
function GetClassNum(strClassId as string) as string
dim conn as SQLConnection
conn=getConn()
dim sqlCmd as SqlCommand
dim strSQL as string
dim numRead as SQLDataReader
strSQL="select count(*) as ccount from lanmu where classid='" & strClassId & "'"
sqlCmd=new sqlCommand(strSQL,conn)
sqlCmd.ActiveConnection.Open()
sqlCmd.Execute(numRead)
numRead.Read()
GetClassNum=numRead(0)
end function
sub WriteLastArticle()
dim conn as SQLConnection
conn=getConn()
dim sqlCmd as SqlCommand
dim strSQL as string
dim sRead as SQLDataReader
strSQL="select top 10 * from lanmu,lanmuclass where lanmu.classid=lanmuclass.classid and lanmu.isuse='1' order by id desc"
sqlCmd=new sqlCommand(strSQL,conn)
sqlCmd.ActiveConnection.open()
sqlCmd.execute(sRead)
response.Write("<p><font color=gray>最近的文章</font></p>")
response.Write("<table border=0 width=100%>")
while(sRead.Read())
response.Write("<tr>")
response.Write("<td width=100% align=left>")
response.Write("[<a href='showarticle.asp?classid=" & sRead("classid") & "'>" & sRead("classname") & "</a>]")
response.Write("<a href='viewarticle.asp?id=" & sRead("id") & "' target='_blank'>" & sRead("title") & "</a><font color=gray size=1>" & sRead("dtime") & "</gray>")
response.Write("</td>")
response.Write("</tr>")
End While
response.Write("</table>")
end sub
sub WriteMostClick()
dim conn as SQLConnection
conn=getConn()
dim sqlCmd as SqlCommand
dim strSQL as string
dim sRead as SQLDataReader
strSQL="select top 10 * from lanmu,lanmuclass where lanmu.classid=lanmuclass.classid and lanmu.isuse='1' order by viewnum desc"
sqlCmd=new sqlCommand(strSQL,conn)
sqlCmd.ActiveConnection.open()
sqlCmd.execute(sRead)
response.Write("<p><font color=gray>最近的文章</font></p>")
response.Write("<table border=0 width=100%>")
while(sRead.Read())
response.Write("<tr>")
response.Write("<td width=100% align=left>")
response.Write("[<a href='showarticle.asp?classid=" & sRead("classid") & "'>" & sRead("classname") & "</a>]")
response.Write("<a href='viewarticle.asp?id=" & sRead("id") & "' target='_blank'>" & sRead("title") & "</a><font color=gray size=1>" & sRead("dtime") & "</gray>")
response.Write("</td>")
response.Write("</tr>")
End While
response.Write("</table>")
end sub
</script>
<html>
<head>
<title>豆腐技術站-->技術專欄</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Description" Content="探討ASp,Php 編程,介紹Visual Basic ,Visual C++
等業界最新技術 並提供 免費的各種服務 包括 免費統計系統,免費調查
並提供 招聘網站和 同學錄 的服務">
<meta name="Keywords" Content="探討ASp,Php 編程,介紹Visual Basic ,Visual C++
等業界最新技術 並提供 免費的各種服務 包括 免費統計系統,免費調查
並提供 招聘網站和 同學錄 的服務">
<link REL="SHORTCUT ICON" href="http://www.asp888.net/site.ico">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<link rel="stylesheet" type="text/css" href="/doufu.css">
</head>
<body>
<!--廣告開始-->
<img src="http://edu.cnzz.cn/NewsInfo/images/banner.gif">
<!--廣告結束-->
<hr>
<%WriteLanmuClass%>
<hr>
<%
WriteLastArticle
WriteMostClick
%>