Solved

Getting a TOO FEW PARAMETERS error.  Can't figure it out

Posted on 2003-12-11
16
237 Views
Last Modified: 2013-12-24
Here is some of the error code

Error Executing Database Query.
[MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.

The Error Occurred in C:\CFusionMX\wwwroot\gamecube\article_edit.cfm: line 14

12 : postedemail='#TRIM(FORM.postedemail)#'
13 : WHERE articleID=<cfqueryparam value="#FORM.articleID#" cfsqltype="cf_sql_integer">
14 : </CFQUERY>

SQL UPDATE articles SET gamedID=1, typeID=5, articletitle='New Metroid Preview', articletext='Whoa, new one baby', articledescription='New one', articledate=5/5/93, postedby='New one', postedemail='New one' WHERE articleID= (param 1)


Now, I have a page that is used for inserting/updating depending on the variables being passed.

Well, it has no problem inserting information into a database, but I am receiving the above error when updating and I can't figure it out for the life of me.

Here is the code that seems to be in the problem.

<cfset EditMode=IsDefined("FORM.articleID")>
<cfif EditMode>
<CFQUERY datasource="#dsn#">
UPDATE articles
SET gamedID=#FORM.gameID#,
typeID=#FORM.articletypes#,
articletitle='#TRIM(FORM.articletitle)#',
articletext='#TRIM(FORM.articletext)#',
articledescription='#TRIM(FORM.articledescription)#',
articledate=#FORM.articledate#,
postedby='#TRIM(FORM.postedby)#',
postedemail='#TRIM(FORM.postedemail)#'
WHERE articleID=<cfqueryparam value="#FORM.articleID#" cfsqltype="cf_sql_integer">
</CFQUERY>

Well, as you can see, it appears I am using only 1 parameter, articleID=#FORM.articleID#, but I can't figure out why its giving me an error.

ANy help
Thanks
Bryan
0
Comment
Question by:jag5311
16 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 9926337
try include a single quote for date field as well.

articledate='#FORM.articledate#',


hongjun
0
 
LVL 12

Expert Comment

by:jyokum
ID: 9926354
use cfqueryparam for all your fields and make sure that you have all your columns spelled correctly

<CFQUERY datasource="#dsn#">
UPDATE articles
SET gamedID=<cfqueryparam value="#FORM.gameID#" cfsqltype="cf_sql_integer">,
typeID=<cfqueryparam value="#FORM.articletypes#" cfsqltype="cf_sql_integer">,
articletitle=<cfqueryparam value="#TRIM(FORM.articletitle)#" cfsqltype="cf_sql_varchar">,
articletext=<cfqueryparam value="#TRIM(FORM.articletext)#" cfsqltype="cf_sql_varchar">,
articledescription=<cfqueryparam value="#TRIM(FORM.articledescription)#" cfsqltype="cf_sql_varchar">,
articledate=<cfqueryparam value="#FORM.articledate#" cfsqltype="cf_sql_date">,
postedby=<cfqueryparam value="#TRIM(FORM.postedby)#" cfsqltype="cf_sql_varchar">,
postedemail=<cfqueryparam value="#TRIM(FORM.postedemail)#" cfsqltype="cf_sql_varchar">
WHERE articleID=<cfqueryparam value="#FORM.articleID#" cfsqltype="cf_sql_integer">
</CFQUERY>
0
 
LVL 17

Expert Comment

by:anandkp
ID: 9926661
Looks to me that in ur SQl statement

SQL UPDATE articles SET gamedID=1, typeID=5, articletitle='New Metroid Preview', articletext='Whoa, new one baby', articledescription='New one', articledate=5/5/93, postedby='New one', postedemail='New one' WHERE articleID= (param 1)

the "," in ur articletext value = 'Whoa, new one baby' - is the reason for error

Like Jyokum suggested - using CFqueryparam for all ur fields wld help u bypass this & avoid the error !

Also chkup on
1. non-nullable fields [chk if relavent data is passed for not null fields]
2. the value of ArticleID ... I hope thats not getting goofed up some where :)
0
 

Author Comment

by:jag5311
ID: 9928541
Thanks for the help, I will give them a try, but that is weird.  I have another site that uses the same format for the update but it works almost exactly how I have this one setup, and I get no problems.

I don't see why the "comma" in Whoa, new one baby should cause the problem.

I will let you guys know whats going on.

Also, I dno't know how the value of articleID would be goofing since its being passed to the next page

On the previous page before I hit submit, I am able to go up to VIEW SOURCE and I can see that it has the value set to articleID=1, so I know its there

0
 

Author Comment

by:jag5311
ID: 9928896
Hi,

well I have made the changes, and I still get the error.

It appears that I am always 1 parameter short of fullfilling what coldfusion wants.  In the first instance, it wanted 2 parameters and I was only providing 1, now it wants 10, and I am only providing 9 (after all of the CFqueryparam stuff)

I have a feeling this has to do with the articledate

Also, the article title wasn't the problem, because I am having the same error with titles that have no comma's.
0
 
LVL 12

Expert Comment

by:jyokum
ID: 9929094
did you check all your column names? nothing misspelled?
0
 

Author Comment

by:jag5311
ID: 9929118
Nope, I couldn't find anything.

Like I said, i can use INSERT just fine, its when UPDATE is used that gives me the problem
0
 
LVL 12

Expert Comment

by:jyokum
ID: 9929267
show us your insert statement
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:jag5311
ID: 9929525
<CFQUERY datasource="#dsn#">
INSERT INTO articles (gameID,
                                typeID,
              articletitle,
            articletext,
             articledescription,
            articledate,
             postedby,
              postedemail )
VALUES ( #FORM.gameID#,
             #FORM.articletypes#,
             '#TRIM(FORM.articletitle)#',
             '#TRIM(FORM.articletext)#',
             '#TRIM(FORM.articledescription)#',
             #FORM.articledate#,
             '#TRIM(FORM.postedby)#',
             '#TRIM(FORM.postedemail)#' )
</cfquery>
0
 

Author Comment

by:jag5311
ID: 9930312
I have an idea, how about we start from scratch and you guys tell me exactly what I need to do in order for Access and Coldfusion to work in conjunction with each other with no problems

In Access, what do my preferences need to be, meaning the DATA TYPE, and the FORMAT.

In Coldfusion, what do I need my DateFormat to be?  Do I need it at all?

Lets just get a mimimal one working, and we can work from there.

Thanks
Bryan
0
 
LVL 12

Expert Comment

by:jyokum
ID: 9930333
doesn't really matter what the format is, just use cfqueryparam and the appropriate sql type and it will work
0
 

Author Comment

by:jag5311
ID: 9930398
well, something is wrong

Here are two files

1.  This is the actual Form file, where it will prefill or be blank depending on the articleID that is passed.  This is just the top portion
http://www.btkdesigns.com/editform.htm

This is the input that I use on the page to show the article date
<input name="articledate" size="25" type="text" value="#DateFormat(articledate, "yyyy-mm-dd")#" />

2.  This is the code for the insert and update section after the form in part 1 would have been submitted
http://www.btkdesigns.com/edit-insert.htm

I hope this can shine some light

Another problem I am having is when I INSERT an article, all looks fine and it inserts just fine, but when I go to the edit screen to check out how everything looks in the form, if I typed a date of

1995-12-05

it shows up as  

1895-06-24   or something stupid like that.
0
 

Author Comment

by:jag5311
ID: 9930409
File edit,

the 2nd link should be

http://www.btkdesigns.com/insert-edit.htm

Sorry
0
 

Author Comment

by:jag5311
ID: 9934250
anyone?
0
 
LVL 12

Accepted Solution

by:
jyokum earned 125 total points
ID: 9934302
like I said before... check your column spelling!

you misspelled gameID

UPDATE articles SET gamedID

should be

UPDATE articles SET gameID
0
 

Author Comment

by:jag5311
ID: 9935525
Thank you jyokum.

Well, after looking at code all day, my head starts swimming and things sometimes get passed.  Thanks for the observation.

Bryan
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now