?
Solved

Probelm with update record and delete record!

Posted on 2003-02-27
4
Medium Priority
?
127 Views
Last Modified: 2010-04-25
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
Comment
Question by:ysloo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Expert Comment

by:antman912
ID: 8258947
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
 

Expert Comment

by:antman912
ID: 8258967
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
 
LVL 5

Expert Comment

by:zenlion420
ID: 9907727
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
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 9952854
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question