coolidge
2009-03-11 13:59:55 UTC
I'm trying to insert values from a list into a database (Access or SQL 2005).
<cfloop list="#form.txtEntry#" index="i">
<CFQUERY NAME="insRecords" DATASOURCE="MyDB">
insert into tblColors(txtEntry, txtName)
values('#i#', '#form.txtName#')
</CFQUERY>
Some of the values in the list have commas. Here are three list items, for
example:
red, white and blue
orange
purple
I want the value 'red, white and blue' to insert as one record, but my query
is actually inserting it as two records (presumably because of the comma).
It's inserting 'red' as one record and 'white and blue' as another. Could
anyone recommend a way for this to work the way I want? Thanks so much...
<cfloop list="#form.txtEntry#" index="i">
<CFQUERY NAME="insRecords" DATASOURCE="MyDB">
insert into tblColors(txtEntry, txtName)
values('#i#', '#form.txtName#')
</CFQUERY>
Some of the values in the list have commas. Here are three list items, for
example:
red, white and blue
orange
purple
I want the value 'red, white and blue' to insert as one record, but my query
is actually inserting it as two records (presumably because of the comma).
It's inserting 'red' as one record and 'white and blue' as another. Could
anyone recommend a way for this to work the way I want? Thanks so much...