Implement web-based event calendars with ASP and SQL
This article describes how to establish a web-based calendar, while providing a process of establishing a Web site for unfamiliar with Active Server Pages (ASP), SQL and ADO, and provides Web site scalability as well as experienced developers. skill. With the development of network applications, web-based calendars are increasingly attached to people. For important events such as deadlines or schedules, or when they are vacation, Web-based calendars are useful. This article describes how ASPs in IIS and SQL Server build a very simple Web-based calendar and allow you to share your schedule or manage a group of people with others. Establishing a SQL server side For the web calendar, we only save only one text string indicating the nature of the event, and the string is up to 100 characters. The design source code is as follows:
Calendar.sql-- Create Table create table Schedule (idSchedule smallint identity primary key, dtDate smalldatetime not null, vcEvent varchar (100) not null) go-- stored procedure create procedure GetSchedule (@nMonth tinyint, @nYear smallint) asselect idSchedule, convert (varchar, datepart (dd, dtDate)) 'nDay', vcEventfrom Schedulewhere datepart (yy, dtDate) = @nYear and datepart (mm, dtDate) = @nMonthorder by datepart (dd, dtDate) gocreate procedure AddEvent (@vcDate varchar (20), @vcevent varchar (100)) asinsert scheduleselect @vcdate, @vcevent Gocreate Procedure deleteEvent (@idschedule smallint) asdelete schedule where idschedule = @idschedulego
Design ASP client
The following figure is the main user interface of the web calendar, and the user can see which events are arranged. In addition, the link to the bottom can be flipped before and after the calendar.
The implementation code of the ASP is as follows:
Header.asp <@ language = "VBScript" EnableSessionState = false%> <% "Purpose: The header includes files used to start all pages' also include global functions option explicitresponse.buffer = trueresponse.expires = 0sub doheader (strtitle)% >
Optimization performance
ASP makes it easy to build a web page, but if you want to build a site that can accommodate a large number of users, you need to carefully consider encoding. The following writers will introduce readers to enhance several ways based on web calendar scalability, which can also be used to improve any performance based on ASP-based Web site.
SQL optimization
A simple way to improve site performance is to add an index to the Date field of the Schedule table, so it will look for a given date, thus will speed up the getevent store procedure. For small sites, we can install SQL and IIS on the same server. Once the site access starts to grow, we can move SQL to its own server. When the number of visits is further increased, we can add a part to the same SQL server. Multiple IIS servers. If the traffic of the SQL server is excessively increased, you can divide the data to a different server, we can assign an odd month to a server, assign even months to another server, of course, this needs to modify the Header. GetDataConnection in the ASP so that it provides you with the correct connection based on this month. 2.ASP optimization
The main optimization method of the ASP interpretation will use a cache page so that they do not need to explain them each read. The easiest way to do this is to use the ASP Application object. To do this, you only need to save HTML to application variables (such as Calendar07-2000) with months and year names. Then, when you display the Event Calendar page, you first check if the calendar has been saved in the application variable, if so, just retrieve it, this way will greatly speed up the query process of the website. The following code shows this work process:
<< Do Header >> Showcalendar (NMONTH, NYEAR) << Do Footer >> Sub Showcalendar (NMONTH, NYEAR) IF Application ("Calendar" && NMONTH && "-" && nyear) = "" "" b1nd calendar >> Application ("Calendar" && nmonth && "-" && nyear) = << Calendar >> End IfResponse.write application ("Calendar" && nmonth && "-" && nyear) End Sub
Of course, when you change the event of a month, you need to empty the application variables of the month to reflect changes in these events.
safety
There are several ways to realize security on this site. For intranet sites, Windows NT-based authentication is the easiest to set, because your users will likely have already logged in to the network. You allow all users to view the Event Calendar page, but only administrators can access the Add / REMOVE EVENTS page. If you care about the audit, you can easily modify the AddEvent and DeleteEvent procedures to save their information to the audit table. You can also ensure that IIS performs log records for each page of the query string and the user, then analyze the logs one by one to determine when and what is done, this is very simple. This article demonstrates the basic process based on the web calendar, which is simple, but it can be easily extended to a functionally complete site. Limited to the space, the author no longer introduces, and the readers of interest can find specific implementation steps in the infoCD eighth disc.