使用asp方便的建立自己網(wǎng)站的每日更新 每日更新是什么東東我想大家也都應(yīng)該知道把, 其實(shí)有點(diǎn)象現(xiàn)在很多新聞網(wǎng)站的更新,下面介紹如何讓你的 網(wǎng)站的內(nèi)容每天自動(dòng)更新 下面的代碼適用于: 1.使用任何ODBC兼容的數(shù)據(jù)庫 2。很方便的插入到你現(xiàn)有的ASP程序中 如何保存更新內(nèi)容呢? 數(shù)據(jù)庫結(jié)構(gòu):(一共三個(gè)字段) QuoteID(Long ),Quote(String ),Author(String) 下面一個(gè)技巧是如何讓更新顯示在任意一個(gè)頁面上呢? 我們只要把更新內(nèi)容和作者當(dāng)返回值送給調(diào)用的頁面即可。 代碼如下,其中l(wèi)ogic是一個(gè)隨機(jī)數(shù),表示隨機(jī)從數(shù)據(jù)庫中顯示哪個(gè)記錄: <% Sub GetQuote(byVal strQuote, byval strAuthor) Dim intMaxID Dim intRecordID dim strSQL Dim oConn Dim oRS
set oConn = Server.CreateObject("ADODB.Connection") oConn.Open "Database=mydb;DSN=Quotes;UID=sa;PassWord=;"
strSQL = "SELECT MaxID=max(QuoteId) from Quotes" Set oRS = oConn.Execute(strSQL) If oRS.EOF Then strQuote = "站長太懶了,今天沒有更新內(nèi)容." strAuthor = "呵呵" Exit Sub Else intMaxID = oRS("MaxID") End If
Randomize intRecordID= Int(Rnd * intMaxID) + 1 strSQL = "Select * from quotes where QuoteID=" & intRecordID & ";" Set oRS = oConn.Execute(strSQL) If oRS.EOF Then strQuote = "站長太懶了,今天沒有更新內(nèi)容." strAuthor = "呵呵" Exit Sub Else oRS.MoveFirst strQuote = oRS("Quote") strAuthor = oRS("Author") End If
oRS.Close oConn.Close Set oRS = Nothing set oConn = Nothing End Sub %>