Implement web-based event calendars with ASP and SQL

xiaoxiao2021-03-06  102

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)% > Event Calendar - <% = strtitle%> </ title> </ head> <body bgcolor = "white" link = "blue" alink = "blue" VLINK = "blue"> <basefont face = "verdana, arial"> <center> <h1> Event Calendar </ h1> <h3> <% = strTitle%> </ h3> <% end subfunction GetDataConnection () dim oConn, strConnSet oConn = Server.CreateObject ( "ADODB.Connection") strConn = "Provider = SQLOLEDB; Data Source = adspm; Initial Catalog = TeamWeb;" strConn = StrConn && "User ID = Teamweb; Password = x" Oconn.open strconnet getDataConnection = Oconnend Function%> Using ADO, we can easily connect the ASP page to the SQL database. First we have to create a connection to the database. In order to obtain a recordset, we want to call the EXECUTE method of the Connection object, incorporate the text string of the command you want to execute, once a recordset, you can cycle it. Header.asp contains functions for obtaining data connection, which means that if the data source changes, we only have a location to edit connection information (servers, users, and passwords). Note that as a result, we must use the set command to send new connections at the end of the function.</p> <p>Optimization performance</p> <p>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.</p> <p>SQL optimization</p> <p>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</p> <p>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:</p> <p><< 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</p> <p>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.</p> <p>safety</p> <p>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.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-100323.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="100323" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.043</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'KUvrbYd91HyTKH8OILm35Da2qrV_2BLbuNzPhuEmlLKpb9_2BMM1K8jerolVIYZO_2B_2BE_2BCP0cioQbgDCXSHoKJSTd7w_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>