This article introduces how to build a web-based calendar, and provides developers who are not familiar with ActiveServerPages (ASP), SQL and ADO to introduce the process of building a web site, and also provides experienced developers with tips on the scalability of the web site.
With the development of web applications, web-based calendars are increasingly valued, and web-based calendars are useful for displaying important events such as deadlines or schedules, or showing who is taking time off when. This article describes how to use ASPs within IIS and SQLServer to build a very simple web-based calendar and allows you to share your schedule with others or manage a group of people's calendar.
Establish SQL Server
For the Web Calendar, we only need to save a text string indicating the nature of the event on the server side, and the string is up to 100 characters long. The design source code is as follows:
Calendar.sql
--Create a table
createtableSchedule
(
idSchedulesmalintidentityprimarykey,
dtDatesmalldatetimenotnull,
vcEventvarchar(100)notnull
)
go
--Stored Procedure
createprocedureGetSchedule(@nMonthtinyint,@nYearsmalllint)
as
selectidSchedule,convert(varchar,datepart(dd,dtDate))'nDay',vcEvent
fromSchedule
wheredatepart(yy,dtDate)=@nYearanddatepart(mm,dtDate)=@nMonth
orderbydatepart(dd,dtDate)
go
createprocedureAddEvent(@vcDatevarchar(20),@vcEventvarchar(100))
as
insertSchedule
select@vcDate,@vcEvent
go
createprocedureDeleteEvent(@idSchedulesmalint)
as
deleteSchedulewhereidSchedule=@idSchedule
go
Designing an ASP client
The following figure is the main user interface of the Web calendar, where users can see which events are scheduled. Also, use the link at the bottom to flip around the calendar by month.
The implementation code of ASP is as follows:
header.asp
<@LANGUAGE="VBSCRIPT"
ENABLESESSIONSTATE=False%>
<%
'Purpose: The header includes files used to start all pages
'Also include global functions
OptionExplicit
Response.Buffer=True
Response.Expires=0
subDoheader(strTitle)
%>
<html>
<head>
<METAHTTP-EQUIV="Content-Type"CONTENT="text/html;charset=gb2312">
<title>EventCalendar-<%=strTitle%></title>
</head>
<bodybgcolor="white"link="blue"link="blue"vlink="blue">
<basefontface="Verdana,Arial">
<center><h1>EventCalendar</h1>