• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 128
  • Last Modified:

Probelm with update record and delete record!

hi experts,
i musing access as my DB and coldfusion.i m trying to do update record and delete record funtions for user to modify the db.i followed the help instruction in  Dreamweaver MX  but still can't  work out!i don't know what's wrong with that!please help ,it's urgent! Thank You!

p/s: here is the source code of my update record page.

  <cfparam name="FORM.No" default="1">
<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfif IsDefined("FORM.MM_UpdateRecord") AND FORM.MM_UpdateRecord EQ "form2">
  <cfquery datasource="dbppa">
  UPDATE messageI SET "Date"=
  <cfif IsDefined("FORM.Date") AND #FORM.Date# NEQ "">
    '#FORM.Date#'
    <cfelse>
    NULL
  </cfif>
  , Username=
  <cfif IsDefined("FORM.Username") AND #FORM.Username# NEQ "">
    '#FORM.Username#'
    <cfelse>
    NULL
  </cfif>
  , Message=
  <cfif IsDefined("FORM.Message") AND #FORM.Message# NEQ "">
    '#FORM.Message#'
    <cfelse>
    NULL
  </cfif>
  WHERE "No"=#FORM.No#
  </cfquery>
  <cflocation url="result2.cfm">
</cfif>
<cfquery name="update" datasource="dbppa">
SELECT * FROM messageI WHERE "No" = #FORM.No#
</cfquery>
<html>
<head>
<title>Untitled Document</title>

</head>

<body>
<table width="561" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutDefaultTable-->
  <tr>
    <td height="81" colspan="4" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
  </tr>
  <tr>
    <td height="63" colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
    <td colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
  </tr>
  <tr>
    <td width="126" height="29">&nbsp;</td>
    <td width="149">&nbsp;</td>
    <td width="145"></td>
    <td width="141"></td>
  </tr>
  <tr>
    <td height="56">&nbsp;</td>
    <td colspan="2" valign="top">&nbsp;
       
      <form name="form1">
      </form>
      <p>&nbsp;</p>
 
      <form method="post" name="form2" action="<cfoutput>#CurrentPage#</cfoutput>">
        <table align="center">
          <tr valign="baseline">
            <td nowrap align="right">Date:</td>
            <td><input type="text" name="Date" value="<cfoutput>#update.Date#</cfoutput>" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Username:</td>
            <td><input type="text" name="Username" value="<cfoutput>#update.Username#</cfoutput>" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right" valign="top">Message:</td>
            <td> <textarea name="Message" cols="50" rows="5"><cfoutput>#update.Message#</cfoutput></textarea>
            </td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">&nbsp;</td>
            <td><input type="submit" value="Update Record"></td>
          </tr>
        </table>
        <input type="hidden" name="MM_UpdateRecord" value="form2">
        <input type="hidden" name="No" value="<cfoutput>#update.No#</cfoutput>">
      </form>
      <p>&nbsp;</p>
  </td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>

please help!
thanks again!

ys.
0
ysloo
Asked:
ysloo
  • 2
1 Solution
 
antman912Commented:
try putting the set value into the <cfif> statement:

 <cfparam name="FORM.No" default="1">
<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfif IsDefined("FORM.MM_UpdateRecord") AND FORM.MM_UpdateRecord EQ "form2">
 <cfquery datasource="dbppa">
 UPDATE messageI
SET "Date"=
 <cfif IsDefined("FORM.Date") AND #FORM.Date# NEQ "">
   '#FORM.Date#'
   <cfelse>
   NULL
 </cfif>
 , Username=
 <cfif IsDefined("FORM.Username") AND #FORM.Username# NEQ "">
   '#FORM.Username#'
   <cfelse>
   NULL
 </cfif>
 , Message=
 <cfif IsDefined("FORM.Message") AND #FORM.Message# NEQ "">
   '#FORM.Message#'
   <cfelse>
   NULL
 </cfif>
 WHERE "No"=#FORM.No#
 </cfquery>
 <cflocation url="result2.cfm">
</cfif>
<cfquery name="update" datasource="dbppa">
SELECT * FROM messageI WHERE "No" = #FORM.No#
</cfquery>
<html>
<head>
<title>Untitled Document</title>

</head>

<body>
<table width="561" border="0" cellpadding="0" cellspacing="0">
 <!--DWLayoutDefaultTable-->
 <tr>
   <td height="81" colspan="4" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
 </tr>
 <tr>
   <td height="63" colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
   <td colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
 </tr>
 <tr>
   <td width="126" height="29">&nbsp;</td>
   <td width="149">&nbsp;</td>
   <td width="145"></td>
   <td width="141"></td>
 </tr>
 <tr>
   <td height="56">&nbsp;</td>
   <td colspan="2" valign="top">&nbsp;
     
     <form name="form1">
     </form>
     <p>&nbsp;</p>
 
     <form method="post" name="form2" action="<cfoutput>#CurrentPage#</cfoutput>">
       <table align="center">
         <tr valign="baseline">
           <td nowrap align="right">Date:</td>
           <td><input type="text" name="Date" value="<cfoutput>#update.Date#</cfoutput>" size="32"></td>
         </tr>
         <tr valign="baseline">
           <td nowrap align="right">Username:</td>
           <td><input type="text" name="Username" value="<cfoutput>#update.Username#</cfoutput>" size="32"></td>
         </tr>
         <tr valign="baseline">
           <td nowrap align="right" valign="top">Message:</td>
           <td> <textarea name="Message" cols="50" rows="5"><cfoutput>#update.Message#</cfoutput></textarea>
           </td>
         </tr>
         <tr valign="baseline">
           <td nowrap align="right">&nbsp;</td>
           <td><input type="submit" value="Update Record"></td>
         </tr>
       </table>
       <input type="hidden" name="MM_UpdateRecord" value="form2">
       <input type="hidden" name="No" value="<cfoutput>#update.No#</cfoutput>">
     </form>
     <p>&nbsp;</p>
 </td>
   <td>&nbsp;</td>
 </tr>
</table>
</body>
</html>
0
 
antman912Commented:
Sorry, hit submit to soon... I ment this:

 <cfparam name="FORM.No" default="1">
<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfif IsDefined("FORM.MM_UpdateRecord") AND FORM.MM_UpdateRecord EQ "form2">
 <cfquery datasource="dbppa">
 UPDATE messageI
 SET

 <cfif IsDefined("FORM.Date") AND #FORM.Date# NEQ "">
    Date ='#FORM.Date#',
 </cfif>

 <cfif IsDefined("FORM.Username") AND #FORM.Username# NEQ "">
   Username = '#FORM.Username#',
 </cfif>

 <cfif IsDefined("FORM.Message") AND #FORM.Message# NEQ "">
   Message = '#FORM.Message#'
 </cfif>

 WHERE "No"=#FORM.No#
 </cfquery>
 <cflocation url="result2.cfm">
</cfif>

<cfquery name="update" datasource="dbppa">
  SELECT *
  FROM messageI
  WHERE "No" = #FORM.No#
</cfquery>
0
 
zenlion420Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ - no points refunded

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

zenlion420
EE Page Editor
0
 
GhostModCommented:
PAQed - no points refunded (of 50)

GhostMod
Community Support Moderator
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now