ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 2nd, 2005, 11:30 AM
Caden Caden is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 270 Caden User rank is Private First Class (20 - 50 Reputation Level)Caden User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 6 h 57 m 16 sec
Reputation Power: 4
Add/Update

Hey all, quick question

I've built myself a page that adds/updates depnding on if it has been passed an ID through the URL.

Here is a piece of code...

<CFFORM Action="edit2.cfm">
<CFIF EditMode>
<CFOUTPUT>
<Input Type="hidden" Name="ID" value="#portfo.ID#">
</CFOUTPUT>
</CFIF>

So, when I am in editmode and I submit the form to go to edit2.cfm, sometimes it gives me an error saying that it can not see the ID and therefore can not update the record.

But I know it should be working, so if I click back and try to update again, eventually it will work.

Sometimes it will even work on the first try.

So, anyone have an idea as to why sometimes it sees the ID field passed and sometimes it won't?

Thanks
Caden

Reply With Quote
  #2  
Old March 2nd, 2005, 11:53 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,648 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 12 h 8 m 8 sec
Reputation Power: 53
No real advice here except that somewhere in your code something is not right. If you were indeed passing the ID as a hidden form field it would be there on the action page. I would suspect that something is interfering with the proper setting of the editMode variable. I'd try some different <cfdump><cfabort> placements to try and determine what the problem is.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old March 2nd, 2005, 12:38 PM
Caden Caden is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 270 Caden User rank is Private First Class (20 - 50 Reputation Level)Caden User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 6 h 57 m 16 sec
Reputation Power: 4
no idea

Alright, I have no idea what is going on. Here's the code, i'm getting frustrated. I made the add and update different pages figuring since there was no problem with the add page...but that didn't help...take a look, maybe it's simple and i'm dumb.

<CFAPPLICATION name="omneraportfolio" sessionmanagement="yes">
<CFIF Not IsDefined ("Session.Auth.IsLoggedIn")>
<CFIF IsDefined("Form.UserLogin")>
<CFINCLUDE Template="logincheck.cfm">
</CFIF>
<CFINCLUDE template="UserLoginForm.cfm">
<CFABORT>
</CFIF>


<CFQUERY datasource="omneraportfolio" name="portfo">
select ID, name, imageoff, imageon, alt, width, height, title, imagesrc, description, project, projdesc, tech, sitelink, location
from portfolio
where ID=#URL.portID#
</CFQUERY>

<CFSET name=Trim(portfo.name)>
<CFSET imageoff=Trim(portfo.imageoff)>
<CFSET imageon=Trim(portfo.imageon)>
<CFSET alt=Trim(portfo.alt)>
<CFSET width=Trim(portfo.width)>
<CFSET height=Trim(portfo.height)>
<CFSET title=Trim(portfo.title)>
<CFSET imagesrc=Trim(portfo.imagesrc)>
<CFSET description=Trim(portfo.description)>
<CFSET project=Trim(portfo.project)>
<CFSET projdesc=Trim(portfo.projdesc)>
<CFSET tech=Trim(portfo.tech)>
<CFSET sitelink=Trim(portfo.sitelink)>
<CFSET location=Trim(portfo.location)>

<CFSET Formtitle="Update a Portfolio Piece">
<CFSET ButtonText="Update">


<CFINCLUDE TEMPLATE="header.cfm">
<CFFORM Action="edit3.cfm">
<CFOUTPUT>
<Input Type="hidden" Name="ID" value="#portfo.ID#">
</CFOUTPUT>
<table align=center>
<tr>
<td>
Form Name:
</td>
<td>
<CFINPUT TYPE="Text" Name="name" value="#name#">
</td>
</tr>
<tr>
<Td>
Image Off:
<Td>
<CFINPUT TYPE="Text" Name="imageoff" value="#imageoff#">
</td>
</tr>
<tr>
<Td>
Image On:
<Td>
<CFINPUT TYPE="Text" Name="imageon" value="#imageon#">
</td>
</tr>
<tr>
<td>
Alt of the image
</td>
<td>
<CFINPUT TYPE="Text" Name="alt" value="#alt#">
</td>
</tr>
<tr>
<td>
Width of image
</td>
<td>
<CFINPUT TYPE="Text" Name="width" value="#width#">
</td>
</tr>
<tr>
<Td>
Height of image
</td>
<td>
<CFINPUT TYPE="text" Name="height" value="#height#">
</td>
</tr>
<tr>
<Td>
Title
</td>
<td>
<CFINPUT TYPE="text" Name="title" value="#title#">
</td>
</tr>
<tr>
<Td>
Image Location
</td>
<td>
<CFINPUT TYPE="text" Name="imagesrc" value="#imagesrc#">
</td>
</tr>
<tr>
<Td>
Description of Company
</td>
<td>
<CFINPUT TYPE="text" Name="description" value="#description#">
</td>
</tr>
<tr>
<Td>
Project
</td>
<td>
<CFINPUT TYPE="text" Name="project" value="#project#">
</td>
</tr>
<tr>
<Td>
Project Description
</td>
<td>
<CFINPUT TYPE="text" Name="projdesc" value="#projdesc#">
</td>
</tr>
<tr>
<Td>
Technology Used
</td>
<td>
<CFINPUT TYPE="text" Name="tech" value="#tech#">
</td>
</tr>
<tr>
<Td>
Site Link
</td>
<td>
<CFINPUT TYPE="text" Name="sitelink" value="#sitelink#">
</td>
</tr>
<tr>
<Td>
Location</td>
<td>
<CFINPUT TYPE="text" Name="location" value="#location#">
</td>
</tr>
<tr>
<Td>
<CFOUTPUT>
<input type="submit" value="#ButtonText#">
</CFOUTPUT>
</td>
</tr>

</table>
</CFFORM>
<CFINCLUDE TEMPLATE="footer.cfm">

Reply With Quote
  #4  
Old March 2nd, 2005, 01:10 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,648 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 12 h 8 m 8 sec
Reputation Power: 53
Please post the actual error, looking at the code is useless if I don't know what the problem is. Thanks.

Reply With Quote
  #5  
Old March 2nd, 2005, 01:24 PM
Caden Caden is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 270 Caden User rank is Private First Class (20 - 50 Reputation Level)Caden User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 6 h 57 m 16 sec
Reputation Power: 4
Error - Grasshopper disassembled

Here is the error, keep in mind, the first three I updated something, it worked, took me until the 4th try for the error to hit




Primary key field "ID," not found.
The field "ID," was not found in the Form input. This field is required in order to do an UPDATE because it is part of the primary key for the "portfolio" table.

The error occurred in D:\webs\omnera\edit3.cfm: line 1

1 : <CFUPDATE Datasource="omneraportfolio" TABLENAME="portfolio">
2 : <cflocation url="admin.cfm">



--------------------------------------------------------------------------------


Please try the following:
Check the CFML Reference Manual to verify that you are using the correct syntax.
Search the Knowledge Base to find a solution to your problem.


Browser Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
Remote Address 10.0.0.79
Referrer http://www.omnera.com/portfolioupdate.cfm?portID=15
Date/Time 02-Mar-05 01:22 PM

Stack Trace (click to expand)
at cfedit32ecfm1135037109.runPage(D:\webs\omnera\edit3.cfm:1)


coldfusion.tagext.sql.UpdateTag$MissingPrimaryKeyException: Primary key field "ID," not found.
at coldfusion.tagext.sql.UpdateTag.setColumnList(Unknown Source)
at coldfusion.tagext.sql.InsertTag.doStartTag(Unknown Source)
at coldfusion.runtime.CfJspPage._emptyTag(Unknown Source)
at cfedit32ecfm1135037109.runPage(D:\webs\omnera\edit3.cfm:1)
at coldfusion.runtime.CfJspPage.invoke(Unknown Source)
at coldfusion.tagext.lang.IncludeTag.doStartTag(Unknown Source)
at coldfusion.filter.CfincludeFilter.invoke(Unknown Source)
at coldfusion.filter.ApplicationFilter.invoke(Unknown Source)
at coldfusion.filter.PathFilter.invoke(Unknown Source)
at coldfusion.filter.ExceptionFilter.invoke(Unknown Source)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(Unknown Source)
at coldfusion.filter.BrowserFilter.invoke(Unknown Source)
at coldfusion.filter.GlobalsFilter.invoke(Unknown Source)
at coldfusion.filter.DatasourceFilter.invoke(Unknown Source)
at coldfusion.CfmServlet.service(Unknown Source)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:241)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:198)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:348)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:294)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

Reply With Quote
  #6  
Old March 2nd, 2005, 02:07 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,648 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 12 h 8 m 8 sec
Reputation Power: 53
First I highly recommend writing your own SQL update statement. cfupdate is not widely used because it is not flexible.

Second, if the variable form.id is not being passed to the update page (you should verify that by using <cfdump var="#form#"><cfabort> on the update page and check what is in the form scope), then the problem is in the form. If that turns out to be the case, try doing a <cfdump var="#portfo#"> on the form page to confirm that the ID field is coming back in the query and that it has a value that you are expecting.

If none of these work, I recommend stripping everything away and testing at the most basic level with a very simple query and a very simple form, and build up from there to determine where the error is coming from.

I have written literally thousands of form and database update code files that work fine, so the problem must be there somewhere.

Reply With Quote
  #7  
Old March 2nd, 2005, 03:59 PM
Caden Caden is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 270 Caden User rank is Private First Class (20 - 50 Reputation Level)Caden User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 6 h 57 m 16 sec
Reputation Power: 4
fixed

Thanks for the tip that CFUPDATE was weak, I wrote my own SQL update and the problem disapeared.

Thanks!
Caden

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Add/Update


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway