chunfeng.asp
' 該頁面可以看到已安排了哪些事情,並在底部連結可按月前後翻動.
' 該程式碼封裝含獲得資料連線的函數,如果資料來源一旦有變化,則只有一個位置需要編輯串連資訊(伺服器、使用者和口令).
<@ LANGUAGE="VBscript"
ENABLESESSIONSTATE = False %>
<%
' 表頭包括用來啟動所有頁的檔案,包括全域函數.
Option Explicit
Response.Buffer = True
Response.Expires = 0
sub Dochunfeng(strtitle)
%>
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<title>星河影動之精英排程<%= strtitle %></title>
</head>
<body bgcolor="white" link="blue" alink="blue" vlink="blue">
<basefont face="Verdana, Arial">
<center><h1>我的排程</h1>
<h3><%= strtitle %></h3>
<%
' 建立資料庫連接.
end sub
' 調用Connection 對象 Execute 方法,將希望執行的命令的文本字串傳入,一旦有了記錄集,就可在其中迴圈.
function GetDataConnection()
dim oConn, strConn
Set oConn = Server.CreateObject("ADODB.Connection")
strConn = "Provider=SQLOLEDB; Data Source=adspm; Initial Catalog=TeamWeb; "
strConn = strConn && "User Id=TeamWeb; Password=x"
oConn.Open strConn
' 作為結果,使用set命令傳出新串連.
set GetDataConnection = oConn
end function
%>
Calendar.sql
-- 建立SQL伺服器端.只需儲存表明事件性質的一個文本字串(最長為100個字元)即可.
-- 建立表
create table Schedule
(
idSchedule smallint identity primary key,
dtDate smalldatetime not null,
vcEvent varchar(100) not null
)
go
-- 預存程序
create procedure GetSchedule (@nMonth tinyint, @nYear smallint)
as
select idSchedule, convert(varchar, datepart(dd, dtDate)) 'nDay', vcEvent
from Schedule
where datepart(yy, dtDate) = @nYear and datepart(mm, dtDate) = @nMonth
order by datepart(dd, dtDate)
go
create procedure AddEvent (@vcDate varchar(20), @vcEvent varchar(100))
as
insert Schedule
select @vcDate, @vcEvent
go
create procedure DeleteEvent (@idSchedule smallint)
as
delete Schedule where idSchedule = @idSchedule
go
[1]