July 2000
Intermediate to advanced
492 pages
14h 53m
English
The Active Server Pages equivalent to the earlier CGI applications, which is shown in Example 2.4, is perhaps the simplest of the three applications. First I'll show you the code, then I'll discuss it a bit.
Example B.4. The ASP Equivalent of the CGI Application
<HTML> <HEAD> <TITLE>Language Preference Storage</TITLE> </HEAD> <BODY> <% ' +-------------------------------------+ ' | Local variable declarations. | ' +-------------------------------------+ Dim strUserName Dim strPrefLang Dim adoCon Dim strSQL ' +-------------------------------------+ ' | Create the ADO Connection object. | ' +-------------------------------------+ Set adoCon = Server.CreateObject("ADODB.Connection") adoCon.Open "LangPref" ' +-------------------------------------+ ' | Retrieve the name and preference | ' | field values from the posted form. | ' +-------------------------------------+ strUserName = Request.Form("UsrName") strPrefLang = Request.Form("ProgLang") ' +-------------------------------------+ ' | Create the INSERT statement. | ' +-------------------------------------+ strSQL = "INSERT INTO LangPrefStorage (Name, " strSQL = strSQL & "LangPref) VALUES ('" strSQL = strSQL & strUserName & "', '" strSQL = strSQL & strPrefLang & "')" ' +-------------------------------------+ ' | Execute the SQL statement and close | ' | the ADO connection. | ' +-------------------------------------+ adoCon.Execute strSQL adoCon.Close %> <H1>Thank you, <%=strUserName%>.</h1> Click <A HREF = '/~wsdocs/langform/formsample.htm'> ...Read now
Unlock full access