Solved

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

Posted on 2003-12-11
16
240 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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
 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
Windows Server with multiple sites and SSL 14 67
How can I install php on a ngxin server on droplet 5 142
Use System DSN 6 88
Redundant SQL Servers Without Clustering 7 119
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
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 …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

840 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