Asp/Access Php/MySql

Example of An Delete Preview Form With Key Value Passed as QueryString

And Forward as A Form Hidden Field

Using VBScript, ASP, ADO and a OLEDB Connection

Prepared by Lon Hosford

 
Back to index
 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%
'
'
'   Purpose:      Example of Delete form passing record key value as hidden form value.
'
'   Version:      1.0.0
'
'   Date:         3/4/2004
'
'   Name:         WebClubMemberDeleteRequest.asp
'
'   Changes:
'      1.   Original programming
'
'   Programmer:      Lon Hosford   lon  @  hosfordusa.com
'
'
'

'
'  Use the ADO 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 =       "Select *  "
SQL = SQL & "From WebClubMembers "
SQL = SQL & "Where sMemberNumber = "
SQL = SQL & Request.QueryString("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 preview form 

%>

<html>
<head>
   <title>WebMasters Club Delete Request</title>
</head>

<body>

   <form action="WebClubMemberDeleteResponse.asp" method="post">
      <input type="hidden" name="memNo" value = "<%= oRs.Fields("sMemberNumber").Value %>" >
      <input type="hidden" name="firstName" value = "<%= oRs.Fields("FirstName").Value %>" >
      <input type="hidden" name="lastName" value = "<%= oRs.Fields("LastName").Value %>" >
      <table border = "1" align = "center">
         <tr>
            <td align = "center" colspan = "2">
               <b>WebMasters Club Delete Request</b>
            </td>
         </tr>
         <tr>
            <td align = "right">
               First Name
            </td>
            <td>
               <%= oRs.Fields("FirstName").Value %> 
            </td>
         </tr>
         <tr>
            <td align = "right">
               Last Name
            </td>
            <td>
               <%= oRs.Fields("LastName").Value %> 
            </td>
         </tr>
         <tr>
            <td align = "right">
               Web Address
            </td>
            <td>
               <%= oRs.Fields("WebAddress").Value %> 
            </td>
         </tr>
         <tr>
            <td align = "right">
               Email address
            </td>
            <td>
               <%= oRs.Fields("EmailAddress").value %> 
            </td>
         </tr>
         <tr>
            <td colspan = "2" align = "center">
               <input type="submit" value="Delete">

            </td>
         </tr>
         <tr>
            <td colspan = "2" align = "center">
               <a href = "WebClubMemberDeleteSearchRequest.asp">Search Another Member to Delete</a>

            </td>
         </tr>
      </table>
               

   </form>

<%

' Release memory resources
' Done automatically when ASP processing ends
' but included as good programm form.
oRs.Close
oConn.Close

%>

</body>
</html>