well, myList is a varchar and listItem would be an int. I believe they are ordered correctly the way I pasted it in here. Am I wrong on this?
----- Original Message ----- From: "Kevin Roche" <[EMAIL PROTECTED]> To: "CF-Talk" <cf-talk@houseoffusion.com> Sent: Saturday, August 05, 2006 2:49 PM Subject: RE: problem with insert > Doug, > > The order of the entries of fieldnames and values has to be the same. > So if you write: > > INSERT INTO sub_categories (sub_category,cat_id ) > > The second value must be an integer. > > Kevin > > > -----Original Message----- > From: Doug [mailto:[EMAIL PROTECTED] > Sent: 05 August 2006 20:52 > To: CF-Talk > Subject: Re: problem with insert > > > ok I did this > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> > <cfset mylist="Advertising,tools"> > <cfloop list="#mylist#" index="listItem"> > <cfquery datasource="classifieds"> > INSERT INTO sub_categories (sub_category,cat_id ) > VALUES (<cfqueryparam value="#myList#">,<cfqueryparam > value="#listItem#">) > </cfquery> > </cfloop> > > and I got this > > ODBC Error Code = 22005 (Error in assignment) > > > [Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the > varchar value 'Advertising' to a column of data type int. > > > > The sub_category field is a data type of varchar, not sure why it wants to > convert it in the first place. > > > > > > ----- Original Message ----- > From: "Jochem van Dieten" <[EMAIL PROTECTED]> > To: "CF-Talk" <cf-talk@houseoffusion.com> > Sent: Saturday, August 05, 2006 9:14 AM > Subject: Re: problem with insert > > > > Doug wrote: > > > > > > I have two tables > > > > > > categories: (This table is populated with the categories already) > > > [id] pri key > > > category > > > > > > sub_categories (This table is empty) > > > [id] pri key > > > cat_id FK to categories.id > > > sub_category > > > > > > I want to insert a comma delimeted list into the sub_categories table. > > > > <cfloop list="#myList#" index="listItem"> > > <cfquery ...> > > INSERT INTO sub_categories (cat_id, sub_category) > > VALUES ( > > <cfqueryparam value="#something#">, > > <cfqueryparam value="#listItem#"> > > ) > > </cfquery> > > </cfloop> > > > > Jochem > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:248896 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4