Forum Moderators: open

Message Too Old, No Replies

Deleting DB records using Frontpage

         

stevelibby

2:21 pm on May 28, 2004 (gmt 0)

10+ Year Member



ok, i want to delete a record in my db via a web interface using frontpage. here is the code below:
<% end if %>
<%
fp_sQry="DELETE * FROM contract_hire WHERE (carID='::CarID::')"
fp_sDefault="CarID="
fp_sNoRecords="<tr><td colspan=16 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="Database5"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&"
fp_iDisplayCols=16
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
is this correct? then why doesnt it work?

Easy_Coder

2:36 pm on May 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried:

fp_sQry = "DELETE contract_hire WHERE (carID=" & CarID & )"

stevelibby

2:40 pm on May 28, 2004 (gmt 0)

10+ Year Member



i am trying but it wont let me save it? it is in web bot, so i cant do it.however i managed
DELETE FROM contract_hire
WHERE CarID=" & CarID &"
But that didnt work.

mattglet

3:00 pm on May 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not familiar with FP functionality, but doesn't there need to be a line where it actually executes the query?

-Matt

stevelibby

3:04 pm on May 28, 2004 (gmt 0)

10+ Year Member



i would asume the web bot does this?
Here is the whole page:
<html>

<head>
<% ' FP_ASP -- ASP Automatically generated by a FrontPage Component. Do not Edit.
FP_CharSet = "windows-1252"
FP_CodePage = 1252 %>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>

<table width="100%" border="1">
<thead>
</thead>
<tbody>
<!--webbot bot="DatabaseRegionStart" s-columnnames s-columntypes s-dataconnection="Database5" b-tableformat="TRUE" b-menuformat="FALSE" s-menuchoice s-menuvalue b-tableborder="TRUE" b-tableexpand="TRUE" b-tableheader="TRUE" b-listlabels="TRUE" b-listseparator="TRUE" i-listformat="0" b-makeform="FALSE" s-recordsource s-displaycolumns s-criteria s-order s-sql="DELETE FROM contract_hire&lt;br&gt;WHERE CarID=&amp;quot; &amp;amp; CarID &amp;amp; &amp;quot;" b-procedure="FALSE" clientside suggestedext="asp" s-defaultfields="" s-norecordsfound="No records returned." i-maxrecords="256" i-groupsize="0" botid="0" u-dblib="../_fpclass/fpdblib.inc" u-dbrgn1="../_fpclass/fpdbrgn1.inc" u-dbrgn2="../_fpclass/fpdbrgn2.inc" tag="TBODY" preview="&lt;tr&gt;&lt;td colspan=64 bgcolor=&quot;#FFFF00&quot; width=&quot;100%&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This is the start of a Database Results region. The page must be fetched from a web server with a web browser to display correctly; the current web is stored on your local disk or network.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;" startspan b-UseDotNET="FALSE" CurrentExt sa-InputTypes b-DataGridFormat="FALSE" b-DGridAlternate="TRUE" sa-CritTypes b-WasTableFormat="TRUE" --><!--#include file="../_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="DELETE FROM contract_hire WHERE CarID="" & CarID & """
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=16 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="Database5"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&"
fp_iDisplayCols=16
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<!--webbot bot="DatabaseRegionStart" endspan i-checksum="2669" --><!--webbot bot="DatabaseRegionEnd" b-tableformat="TRUE" b-menuformat="FALSE" u-dbrgn2="../_fpclass/fpdbrgn2.inc" i-groupsize="0" clientside tag="TBODY" preview="&lt;tr&gt;&lt;td colspan=64 bgcolor=&quot;#FFFF00&quot; width=&quot;100%&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This is the end of a Database Results region.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;" startspan --><!--#include file="../_fpclass/fpdbrgn2.inc"-->
<!--webbot bot="DatabaseRegionEnd" endspan i-checksum="56926" --></tbody>
</table>

</body>

</html>

Easy_Coder

3:35 pm on May 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



actually, I gave you incorrect syntax
fp_sQry = "DELETE contract_hire WHERE (carID=" & CarID & )"

is missing a quote

fp_sQry = "DELETE contract_hire WHERE (carID=" & CarID & ")"

stevelibby

3:54 pm on May 28, 2004 (gmt 0)

10+ Year Member



just tried that and that doesnt work, its doing my head in. Do i need frontpage extensions installed? or could there be an issue with the server as i am able input data but not amend it.

txbakers

4:25 pm on May 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, you will need frontpage extensions installed.

FrontPage is SO UNSTANDARD that you have to have all their supporting files installed for it to function. Whereby if you just wrote the simple code by hand, you wouldn't need those extensions, and people would understand your code.

stevelibby

5:13 pm on May 28, 2004 (gmt 0)

10+ Year Member



i know and understand this however i am currently devoloping my skills but i am not advanced enough yet. so i need the relqatively simple solution for the time being.
So.... are you saying that i need frontpage extentions to be on my server in order for updating and deleting records? But i can creat new records without the server extentions?

mattglet

8:22 pm on May 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Theoretically, you shouldn't even be able to connect to the server with FP if you don't have FPSE installed. Interesting question.

-Matt

stevelibby

8:41 pm on May 28, 2004 (gmt 0)

10+ Year Member



Thank you for that...i have now had the front page extensions installed, first i removed all content inc db and then re uploaded all info.
And it still doesnt work....any ideas?

Spooky

9:56 am on Jun 1, 2004 (gmt 0)

10+ Year Member



Assuming its a numeric field, use the default DRW format :

fp_sQry="DELETE FROM contract_hire WHERE (carID=::CarID::)"

You need to have passed the value from a form field called "CarID" (the value being the record id)

A trick to delete multiple values, is to use "IN"

fp_sQry="DELETE FROM contract_hire WHERE carID IN (::CarID::)"

So, if you have multiple check boxes, all called "CarID" with a value of the record ID, a comma delimited string is passed to the delete statement when you submit.

eg:
fp_sQry="DELETE FROM contract_hire WHERE carID IN (1,2,4,5,7,8)"