发布于2026-07-22 阅读(0)
扫一扫,手机访问
这个页面用来展示已经安排好的日程事项,底部还提供了按月份前后翻动的链接。代码里封装了一个获取数据库连接的函数,这样一旦数据源发生变化,只需要修改一个地方(服务器、用户和口令)就能搞定,维护起来省心不少。
来看看具体的实现。首先是ASP页面头部,它包含所有页面启动时需要的全局函数。
<@ LANGUAGE="VBscript"
ENABLESESSIONSTATE = False %>
<%
Option Explicit
Response.Buffer = True
Response.Expires = 0
sub Dochunfeng(strtitle)
%>
星河影动之精英日程安排<%= strtitle %>
我的日程安排
<%= strtitle %>
<%
' 创建数据库连接.
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
%>
接下来是数据库端的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 上一篇:如何制作一个倒计时的程序?
下一篇:如何在网站中插播广告?
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
正版软件
正版软件
正版软件
正版软件
正版软件
1
2
3
7
8