Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query insert into problem

Status
Not open for further replies.

achai

MIS
May 23, 2000
71
US
erro shows &quot; Too few parameters. Expected 9.&quot;<br>but there are 14 parameters totally. I think that's already too much.<br><br>-----------------------<br>file1:<br>&lt;form action=&quot;file2.cfm&gt;<br>&lt;input type=&quot;text&quot; name=&quot;companyname&quot;&gt;.......<br>.............&lt;/form&gt;<br>------------------------<br>file2:<br>&lt;cfquery datasource=&quot;db1&quot;&gt;<br>INSERT INTO Company(CompanyName, CompanyLegalName, StateofIncorporation, MailingAddress, City, State, Zipcode, Country, PhoneNumber, Customer, Notes, Fax, LastUpdate, LastUpdateUserID)<br>VALUES(#CompanyName#, #CompanyLegalName#, #StateofIncorporation#, #MailingAddress#, #City#, #State#, #Zipcode#, #Country#, #PhoneNumber#, #Customer#, #Notes#, #Fax#, #LastUpdate#, #LastUpdateUserID#)<br>&lt;/cfquery&gt;
 
I'd be willing to bet there is a comma in one of your fields (maybe &quot;MyCompany,Inc.&quot;???), making it look like you have 15 entries in your VALUES clause....<br><br>Try this:<br><FONT FACE=monospace>&lt;cfquery datasource=&quot;db1&quot;&gt;<br>INSERT INTO Company(CompanyName, CompanyLegalName, StateofIncorporation, MailingAddress, City, State, Zipcode, Country, PhoneNumber, Customer, Notes, Fax, LastUpdate, LastUpdateUserID)<br>VALUES('#CompanyName#', '#CompanyLegalName#', '#StateofIncorporation#', '#MailingAddress#', '#City#', '#State#', '#Zipcode#', '#Country#', '#PhoneNumber#', '#Customer#', '#Notes#', '#Fax#', #LastUpdate#, #LastUpdateUserID#)<br>&lt;/cfquery&gt; </font><br>(take out the single quotes where ever you have a numeric database column, maybe zipcode)<br><br>DM
 
I have already taken out of single quote from #zipcode#, #phoneNumber#, #fax#, #LastUpdate#, #LastUpdateUserID#.<br><br>but this time, erro shows &quot;Data type mismatch in criteria expression.&quot;<br><br>actually there are 3 more fields in access, but they are radio type. so i didn't wrote them into these two files. cause according to input type=&quot;radio&quot;, erro also shows &quot;Data type mismatch in criteria expression.&quot;<br><br>
 
problem resolved <b>some</b>. <br>the form must be filled in number where single quote was taken off from parameter.<br><br>&quot;Data type mismatch in criteria expression.&quot; because #customer# is yes/no type in access, and radio type in form.<br><br>how can i make this radio type match to coldfusion query expression?<br><br><br><br>
 
You can access the value by checking if the button is defined, if it has been checked it is defined if it hasn't it's not, so in your query you would do something like:<br><br>INSERT INTO Company (customer, BLA BLA BLA)<br>VALUES (#IIF(IsDefined(&quot;Customer&quot;), &quot;true&quot;, &quot;False&quot;)#, bla, bla, bla)<br><br>Hope this hels, <br><br>Bromrrrr
 
not because of file2's query problem, because cfinput type=&quot;radio&quot; is wrong. but i don't know why. <br><br>erro shows:<br>&quot;Attribute set validation error in tag CFINPUT<br><br>The tag has an invalid attribute combination: the value of the tag switch attribute 'TYPE' which is now 'RADIO' requires a different combination of attributes. For the same switch attribute value the following required attributes have not been provided: (VALUE).&quot;<br><br>
 
problem has been resolved.<br><br>must add value=&quot;&quot; to file1:<br>&lt;cfinput type=&quot;radio&quot; ...
 
Did the query work for you?&nbsp;&nbsp;You should have single quotes around strings and dates, and no quotes for numeric values...
 
yes.<br>single quote for text value.<br>no single quote for numeric values and yes/no(radio) value.
 
Also, a good idea is to have a default value for the radio button in the form handler:<br><br>&lt;cfparam name=&quot;(radiovariablename)&quot; default=0&gt;<br><br>This will provide a default to the radio button and not give you a &quot;parameter not defined&quot; error....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top