Solved

Key Field Problem

Posted on 2000-05-01
8
149 Views
Last Modified: 2013-12-24
Running Cold Fusion 4.0 with MS-Access on a stand-alone test box, I am trying to run a DoEdit but I keep getting an error saying that I have not identified a primary key in the table. I have done this, deleted and re-entered the database in the ODBC datasources and verified it. I still get this error!
Any suggestions?
0
Comment
Question by:jacquard
8 Comments
 
LVL 2

Expert Comment

by:paulkd
ID: 2767170
Hi jacquard,

I've never heard of a DoEdit, but it sounds interesting. Is it an Access 2000 function?
0
 
LVL 5

Expert Comment

by:nathans
ID: 2768032
There is no ColdFusion Function called DoEdit what are you trying to do that is not working?

Nathan Stanford
Mr. ColdFusion
ColdFusion Tips Plus
www.nsnd.com
0
 

Author Comment

by:jacquard
ID: 2768522
Sorry, what I meant to type was that I am trying to do an edit of some records using CFUPDATE. The "DoEdit" is just a call.

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 2

Expert Comment

by:dlewis9
ID: 2769516
If your table has a primary key, then you must send the primary key field value into the CFUPDATE as well..

For example:

PAGE1.CFM

<FORM ACTION="page2.cfm" METHOD="POST">
      <INPUT TYPE="Hidden" NAME="userid" VALUE="1">
      <INPUT TYPE="Hidden" NAME="password" VALUE="test">
      <INPUT TYPE="Submit">
</FORM>

PAGE2.CFM

<CFUPDATE DATASOURCE="mydatasource" TABLENAME="mytablename" DBTYPE="ODBC" FORMFIELDS="userid, password">

If you don't want to use a primary key, you should be able to get around this limitation by just using CFQUERY with an update statement:

<!--- Update all records --->
<CFQUERY NAME="myquery" DATASOURCE="mydatasource">

UPDATE mytablename
SET password = 'test'

</CFQUERY>

I hope that is on the right track of what you are asking..if not, can you post some sample code?
0
 
LVL 1

Expert Comment

by:cfmrulez
ID: 2785858
Hiz!

Jacquard, can you show us the exact error message are you getting. It's also a plus if you can show us the table structure and the cfm code your are getting in trouble.

Thanks,
cfmrulez!
0
 

Author Comment

by:jacquard
ID: 2793133
OK...I think I may have stumbled onto the problem but in doing so uncovered another. My original query read:
<CFUPDATE DATASOURCE="training" TABLENAME="RJITF Courses" dbtype="odbc">

<CFQUERY NAME="GetData" DATASOURCE="training">
SELECT *
FROM RJITF Courses
ORDER BY RecordID
</CFQUERY>

I found that Cold Fusion didn't like spaces in the "TABLENAME" field nor did it like brackets, quotes, or anything else.

After renaming the table to "RJITFCourses" I now get the error:
"ODBC Error Code=22005 (Error in assignment)"

In the debug mode it shows the SQL as:
SQL="UPDATE RJITFCourses SET 'DURATION' =?, 'TARGET'=?, 'PLACE'=?, 'COURSENAME'=?, 'CODE'=?, 'REP_CODE'=?, 'COURSEDESC'=?, WHERE 'RecordID'=?"

Any help before I lose more hair?

thanks

0
 
LVL 9

Accepted Solution

by:
Dain_Anderson earned 100 total points
ID: 2793873
You may want to use a standard SQL query instead of the CFUPDATE. It's much easier
to debug due to being able to see what's going on:

<CFQUERY NAME="updateData" DATASOURCE="training" DEBUG>
    UPDATE      RJITFCourses
    SET         DURATION = '#FORM.duration#',
                TARGET = '#FORM.TARGET#',
                PLACE = '#FORM.PLACE#',
                COURSENAME = '#FORM.COURSENAME#',
                CODE = '#FORM.CODE#',
                REP_CODE = '#FORM.REP_CODE#',
                COURSEDESC = '#FORM.coursedesc#'
    WHERE       RecordID = '#FORM.RecordID#'
</CFQUERY>

Be sure to remove the single quotes around the #FORM.variable# if the destination field is numeric. So, if "REP_CODE" is a numeric field in Access, then you would use:

    REP_CODE = #FORM.REP_CODE#
   
....instead of '#FORM.REP_CODE#'

I'm not sure what your form variable names are, so the above were just guesses.

Hope that helps.
0
 

Author Comment

by:jacquard
ID: 2820432
Although this answer did not resolve the problem, it did put me on the right track to finding the solution myself.

The problem was an error in my code where I included a "hidden" field statement where I shouldn't have.

Many thanks to Dain and everyone else who provided input.

Mike
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
URL redirect 4 57
IIS 8.5 2 52
JVM encoding. How to change encoding. 27 104
Configure IIS to process JSON 10 81
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

822 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