<% ' save as deletearecord.asp %>

<%
Response.expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.CacheControl = "no-cache"
%>
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Select Tables and Fields</title>
<link rel="stylesheet" type="text/css" href="../index.css">
</head>

<body>
<b><font face="Webdings" color="#FF0000">3</font></b><i><font size="1"><a href="http://www.classicaspreference.com/aspexamples/menu.htm">Back
to ASP Examples
Menu</a></font><br>
</i>
<b><font face="Webdings" color="#FF0000">3</font><font size="1"><i><a target="_blank" href="select_database.asp">Back
to Database Selection</a></i></font></b><br>
<b><font face="Webdings" color="#FF0000">3</font></b><i><font size="1"><a href="default.asp">Back to Database Interface Wizard Home Page</a></font><br>
</i>
<b><font face="Webdings" color="#FF0000">4</font><i><font size="1"><a title="Please let me know if this has been helpful." href="mailto:lilpeck@gmail.com?subject=database interface generation wizard">This
script cobbled together by Lil Peck</a></font></i></b><i><br>
</i>
<b><font face="Webdings" color="#FF0000">3</font></b><i><a href="javascript:history.go(-1)" onMouseOver="self.status=document.referrer;return true"><font color="#FF0000"><span style="text-decoration: none; font-weight: 700">Back</span></font></a><p>
<a target="_blank" href="http://www.4guysfromrolla.com/webtech/tips/t062801-1.shtml">Displaying All of the Form Variables</a> -
www.4guysfromrolla.com<br>
Use of <a target="_blank" href="http://www.w3schools.com/tags/ref_ascii.asp">ASCII characters</a>
to replace reserved ASP characters<br>
<a target="_blank" href="http://www.asp101.com/samples/viewasp.asp?file=db_simple.asp">
Simple database connection &amp; display</a> from ASP 101
</p>
<p>
I'm going to write versions to create scripts for database insertions and edits
also. Been up all night doing this one though, time to get some rest. If you
find this database interface generator wizard to be useful, please rate it or
send me an email.
</i></p>
<p>
<a href="http://www.classicaspreference.com/aspexamples/database_interface/testdisplay.asp">
Example of generated script in use.</a>&nbsp;
<font face="Webdings" color="#FF0000">
<b>4</b></font><b><a href="http://classicaspreference.com/aspexamples/counter/download.asp?file=dbinterfacewizard.zip">Download this script set</a><font face="Webdings" color="#FF0000">3</font><font size="4"><br>
&nbsp;</font></b></p>
<p>
<b><font size="4">Here is your wizard-generated asp database display script.
</font></b><i><br>
&nbsp;</i></p>
<p>
<i></p>
<p><b><font color="#FF0000">The variables in red font below are where you will
need to insert the correct fields by hand.</font></b></p>
<p>&lt;%<br>

</i>'save as <%=request.form("Table")%>_deleterecord.asp<br>
<i><br>
if request.form(&quot;key&quot;)=&quot;&quot; then&nbsp; 'the key is your
table field's primary key<br>
response.write &quot;Missing ID Number of Record to Delete!&quot; <br>
response.end<br>
end if<br>
%&gt;</p>
<p>&lt;%<br>
'Our ADO constants we'll need <br>
Const adOpenStatic = 3<font color="blue"><br>
</font>Const adOpenForwardOnly = 0<br>
Const adLockOptimistic = 3<br>
Const adCmdTable = &amp;H0002<br>
Dim conn ' ADO connection<br>
Dim rs ' ADO recordset<br>
Dim strDBPath ' path to our Access database (*.mdb) file<br>
<br>
dim strKey<br>
strKey = request.form(&quot;key&quot;)<br>
<br>
strDBPath = Server.MapPath(&quot;<%=request.form("dbname")%>&quot;)<br>
Set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)<br>
conn.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; &amp; strDBPath &amp; &quot;;&quot;<br>
<br>
%&gt;<br>
&lt;%Set rs = conn.Execute(&quot;SELECT * FROM <%=request.form("Table")%> WHERE
<font color="#FF0000"> <%=request.form("key")%></font>=&quot;&amp; strKey &amp; &quot;&quot;)%&gt; <br>
<br>
<br>
&lt;%<br>
<br>
If request.form(&quot;delete&quot;)=&quot;delete&quot; then</p>
<p>
Set sql = conn.Execute("DELETE * FROM <%=request.form("Table")%> WHERE <%=request.form("key")%>="& strKey & "")<br>
<br>
<br>
response.write&quot;Deleted!&quot;<br>
end if<br>
%&gt; </p>
<p>
Delete record number &lt;%=request.form(&quot;key&quot;)%&gt; from Table &lt;%=request.form(&quot;Table&quot;)%&gt;?</p>
<p>
<br>
&lt;FORM ACTION=&quot;&lt;%=request.servervariables(&quot;script_name&quot;)%&gt;?key=&lt;%=request.form(&quot;key&quot;)%&gt;&quot;
METHOD=POST&gt;<br>
&lt;INPUT TYPE=hidden NAME=&quot;delete&quot; value=&quot;delete&quot;&gt;<br>
&lt;INPUT TYPE=hidden NAME=&quot;Table&quot; value=&quot;&lt;%=request.form(&quot;Table&quot;)%&gt;&quot;&gt;<br>
&lt;INPUT TYPE=hidden NAME=&quot;key&quot; value=&quot;&lt;%=request.form(&quot;key&quot;)%&gt;&quot;&gt;</p>
<p>
<%
response.write"<br><br>"

'Display the Request.Form collection
For Each sItem In Request.Form
dim strCnt, strFld,strTnm

strCnt = Len(sItem)-1
strFld = Right(sItem,(strCnt))
'If NOT Left( item, 1 ) = "T" Then
if NOT sItem = "Table" then
if NOT sItem = "dbname" then
if NOT sItem = "key" then

response.write "&#60;&#37;&#61; " & "rs.Fields("& "&#34;" &strFld &"&#34;"&").Value &#37;&#062;&lt;br&gt;<br>"

end if
end if
end if
Next


%></p>
<p>&nbsp;&lt;INPUT TYPE=SUBMIT value=&quot;Delete&quot;&gt;</p>
<p>&lt;/FORM&gt;</p><br>

</i>
<p><i>&lt;/tr&gt;&lt;/table&gt;&lt;%<br>
rs.Close<br>
Set rs = Nothing<br>
conn.Close<br>
Set conn = Nothing<br>
<br>
%&gt;</i></p>
<p>&nbsp;</p>
</body>

</html>