|
rdouglass -> RE: Do FP2003 forms work without FP extensions? (7/20/2005 14:06:13)
|
Here is sample code for 2 pages. The first one should do the same thing as the code you posted above without using FrontPage extensions. The second page shows you how I'd list those same 4 items from that table for all records. If your DB's are in the fpdb folder, you should be able to check the name of the db to make sure my code uses the right .mdb file and then drop my code on a page in place of yours. Page 1 <html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Results</title>
<link rel="stylesheet" type="text/css" href="http://ctdcf-web/css/dcfstyles.css">
</head>
<body>
<table>
<tbody>
</tbody>
</table>
<table>
<tbody>
<%
DIM myDSN, mySQL, conntemp
myDSN ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("/fpdb/phone.mdb")
'a little function to cleanup the input
FUNCTION cleanString(textIn)
IF trim(textIn&"")>"" THEN
cleanString = trim(Replace(textIn,"'","''")
ELSE
cleanString = ""
END IF
END FUNCTION
IF Request.form("firstname")
mySQL="INSERT INTO Directory (firstname, lastname, telephone, email) VALUES ('" & cleanString(Request.form("firstName")) & "', '" & cleanString(Request.form("lastname")) & "', '" & cleanString(Request.form("telephone")) & "', '" & cleanString(Request.form("email")) & "') "
set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
conntemp.execute(mySQL)
conntemp.close
set conntemp=nothing
END IF
%>
</tbody>
</table>
<p align="center"> </p>
<p align="center"><span lang="en-us"><b>YOUR ENTRY HAS BEEN
SAVED.</b></span></p>
<p align="center"> </p>
<p align="center"><a href="phone_frm.asp">Directory Entry Form</a></p>
<p align="center"><a href="list.asp">Change or View All Directory</a></p>
<p align="center"><a href="phone_search.asp">Search Phone Directory</a></p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
</body>
</html> Page to view those fields: <html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Results</title>
<link rel="stylesheet" type="text/css" href="http://ctdcf-web/css/dcfstyles.css">
</head>
<body>
<%
DIM myDSN, mySQL, conntemp, rstemp, alldata
myDSN ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("/fpdb/phone.mdb")
mySQL="SELECT firstname,lastname,telephone,email FROM Directory"
set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
set rstemp=conntemp.execute(mySQL)
IF rstemp.eof THEN
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
Response.write("No data found for your request.")
ELSE
alldata=rstemp.getrows
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
%>
<table border="0" width="100%">
<tr>
<td width="25%">First Name</td>
<td width="25%">Last Name</td>
<td width="25%">Telephone</td>
<td width="25%">Email</td>
</tr>
<%FOR i = 0 TO ubound(alldata,2)%>
<tr>
<td width="25%"><%=alldata(0,i)%></td>
<td width="25%"><%=alldata(1,i)%></td>
<td width="25%"><%=alldata(2,i)%></td>
<td width="25%"><%=alldata(3,i)%></td>
</tr>
</table>
<%
NEXT
END IF
%>
<p align="center"> </p>
<p align="center"><span lang="en-us"><b>YOUR ENTRY HAS BEEN
SAVED.</b></span></p>
<p align="center"> </p>
<p align="center"><a href="phone_frm.asp">Directory Entry Form</a></p>
<p align="center"><a href="list.asp">Change or View All Directory</a></p>
<p align="center"><a href="phone_search.asp">Search Phone Directory</a></p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
</body>
</html> Don't be initimidated by the array "alldata"; this code is essentially puting the data in a 'spreadsheet-like' memory space and were getting to it by using arraydata(x,y) where x is the column number and y is the row number. One little caveat is that the numbers start with 0 and not 1 so the first cell of the first column is alldata(0,0) and the second column of the first row is alldata(1,0) If you can master these 2 pages, you'll never have to use a DRW again! [:D] ANd trust me, it can enable you to do some nice DB stuff that the DRW can't even imagine. [8|] [;)] You could do this using recordsets but I am not a fan of recordsets 'cause they keep the DB open too long IMO and that is always a consideration of mine; especially when using Access. PS. If this is a new IIS6 install, ensure that ASP pages are enabled. Hope it helps.
|
|
|
|