| |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%
'
'
' Purpose: Example of Update SQL Query using data passed from a form
'
' Version: 1.0.0
'
' Date: 3/4/2004
'
' Name: WebClubMemberUpdateResponse.asp
'
' Changes:
' 1. Original programming
'
' Programmer: Lon Hosford lon @ hosfordusa.com
'
'
'
'
' Use the ASP Server class CreateObject action to gain access
' to the ADODB library on the web server to
' create a connection object from the ADODB library
' Connection class.
' A connection object contains all data and actions for a database
' connection via various techniques.
' We are using the name oConn to represent our connection object.
'
Set oConn = Server.CreateObject("ADODB.Connection")
'
' Use a variable to represent the connection string required
' by the connection object. The variable is optional and
' is a discretion to make futher lines in the code needing this
' easier to read and maintain.
' The connection string is made of three parts.
' 1. PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=
' 2. The server path to our Access database
' Use the ASP Request object
' ServerVariables("APPL_PHYSICAL_PATH")
' to dynamically get the database path.
' 3. The name of the access database
ConnString = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE="
ConnString = ConnString & Request.ServerVariables("APPL_PHYSICAL_PATH")
ConnString = ConnString & "WebMaster.mdb"
'
'
' Testing feedback of the ConnString variable contents.
'
Response.Write "<center>Connection String = " & ConnString & "</center>"
'
' Use the Connection object open action to establish a connection
' to the Access database.
'
oConn.Open ConnString
'
' If needed uncomment next line to see any error messages
' that might be suppressed.
'Response.Write err.number & "- " & err.description
'
' Use a variable to represent the SQL statement.
' The variable is optional and is a discretion to make further
' lines in the code needing this easier to read and maintain.
' Select needed fields and matching records from the table WebClubMembers
SQL = "Update WebClubMembers "
SQL = SQL & "Set "
SQL = SQL & "FirstName = '" & Request.Form("FirstName") & "', "
SQL = SQL & "LastName = '" & Request.Form("LastName") & "', "
SQL = SQL & "WebAddress = '" & Request.Form("WebAddress") & "', "
SQL = SQL & "EmailAddress = '" & Request.Form("EmailAddress") & "' "
SQL = SQL & "Where sMemberNumber = " & Request.Form("memNo")
'
' Testing feedback of the SQL variable contents.
'
Response.Write "<center>SQL Statement = " & SQL & "</center>"
'
' Use the Connection object execute action to submit the
' SQL statement to the database and receive an ADO Recordset
' object back with a pointer to the first record.
set oRs = oConn.Execute (SQL)
' Showing an update form
%>
<html>
<head>
<title>WebMasters Club Update Request</title>
</head>
<body>
<table border = "1" align = "center">
<tr>
<td align = "center" colspan = "2">
<b>WebMasters Club Update Response</b>
</td>
</tr>
<tr>
<td>
<%= Request.Form("FirstName") %>
<%= Request.Form("LastName") %> was updated.
</td>
</tr>
<tr>
<td>
<a href = "WebClubMemberUpdateSearchRequest.asp">Update Another</a>
</td>
</tr>
</table>
<%
' Release memory resources
' Done automatically when ASP processing ends
' but included as good programm form.
oConn.Close
%>
</body>
</html>
|
|