RE: Inserting a delimited list into a database
Oh yeah!!! You are absolutely correct! John, tell Matthew what he's won. ;) -Jake --- Matthew Walker <[EMAIL PROTECTED]> wrote: > Hey ho! The problem is having a table called Update! Try > wrapping [] around > update. > > > -Original Message- > > From: Jake Munson [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, 28 February 2002 10:47 am > > To: CF-Talk > > Subject: Inserting a delimited list into a database > > > > > > I have a form that returns a comma delimited list of > > numbers from some checkboxes that each have the same > name. > > I want to be able to insert a new record in a database > for > > each checkbox that was checked in my form. I figured > that > > if I used a list loop based on my checkbox list, that I > > could have a SQL query insert a record for each value > in > > the list. But it keeps giving me an error on the > insert > > query. Is it not possible to put a cfquery into a > loop? > > Is there a better way to do this? Below is my code. > Below > > that is the error I get. > > > > DELIMITER=","> > > name="serverUpdate"> > > INSERT INTO update (log_id, server) > > VALUES (#logQuery.id#,#ServerID#) > > > > > > > > "[Microsoft][ODBC Microsoft Access Driver] Syntax error > in > > INSERT INTO statement. > > > > The error occurred while processing an element with a > > general identifier of (CFQUERY), occupying document > > position..." > > > > I thought that maybe the problem was that I didn't have > a > > cfoutput around the #ServerID#, but that wasn't the > problem > > either. > > > > Thanks for the help. > > > > -Jake > > > > __ > > Do You Yahoo!? > > Yahoo! Greetings - Send FREE e-cards for every > occasion! > > > __ Get Your Own Dedicated Windows 2000 Server PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: RE: Inserting a delimited list into a database
ahhh yes..but reusable code..portability ;-) Bryan Stevenson VP & Director of E-Commerce Development Electric Edge Systems Group Inc. p. 250.920.8830 e. [EMAIL PROTECTED] - Macromedia Associate Partner www.macromedia.com - Vancouver Island ColdFusion Users Group Founder & Director www.cfug-vancouverisland.com - Original Message - From: <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> __ Why Share? Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: RE: Inserting a delimited list into a database
In SQL Server, the semicolon is not needed. - Original Message - From: Bryan Stevenson <[EMAIL PROTECTED]> Date: Wednesday, February 27, 2002 3:23 pm Subject: Re: RE: Inserting a delimited list into a database > and don't forget the semicolon after the SQL statement to seperate > the SQL for each iteration of the > loop ;-) > > Bryan Stevenson > VP & Director of E-Commerce Development > Electric Edge Systems Group Inc. > p. 250.920.8830 > e. [EMAIL PROTECTED] > - > Macromedia Associate Partner > www.macromedia.com > - > Vancouver Island ColdFusion Users Group > Founder & Director > www.cfug-vancouverisland.com > > - Original Message - > From: <[EMAIL PROTECTED]> > To: "CF-Talk" <[EMAIL PROTECTED]> > Sent: Wednesday, February 27, 2002 2:11 PM > Subject: Re: RE: Inserting a delimited list into a database > > > > In addition, if you want to reduce your database calls, you c an > alway> s > > > > do: > > > > > > > > > > INSERT INTO [update] (log_id, server) > > VALUES (#logQuery.id#,#ServerID#) > > > > > > > > That way, you're only doing one db call, that has multiple statemen > > ts > > > > within it. > > > > Also, you should wrap the dynamic variables in the insert state ment > > > > with tags. > > > > - Original Message - > > From: Matthew Walker <[EMAIL PROTECTED]> > > Date: Wednesday, February 27, 2002 3:07 pm > > Subject: RE: Inserting a delimited list into a database > > > > > Hey ho! The problem is having a table called Update! Try wrap ping > > > > > [] around > > > update. > > > > > > > > > -Original Message- > > > > From: Jake Munson [mailto:[EMAIL PROTECTED]] > > > > Sent: Thursday, 28 February 2002 10:47 am > > > > To: CF-Talk > > > > Subject: Inserting a delimited list into a database > > > > > > > > > > > > I have a form that returns a comma delimited list of > > > > numbers from some checkboxes that each have the same name . > > > > I want to be able to insert a new record in a database fo r > > > > each checkbox that was checked in my form. I figured t hat > > > > if I used a list loop based on my checkbox list, that I > > > > could have a SQL query insert a record for each value in > > > > the list. But it keeps giving me an error on the inser t > > > > query. Is it not possible to put a cfquery into a loop ? > > > > Is there a better way to do this? Below is my code. Below > > > > that is the error I get. > > > > > > > > > ITER=","> > > > > > > > > INSERT INTO update (log_id, server) > > > > VALUES (#logQuery.id#,#ServerID#) > > > > > > > > > > > > > > > > "[Microsoft][ODBC Microsoft Access Driver] Synt ax error > > in > > > > INSERT INTO statement. > > > > > > > > The error occurred while processing an element with a > > > > general identifier of (CFQUERY), occupying document > > > > position..." > > > > > > > > I thought that maybe the problem was that I didn't have a > > > > cfoutput around the #ServerID#, but that wasn't t he probl > > em > > > > either. > > > > > > > > Thanks for the help. > > > > > > > > -Jake > > > > > > > > ___ ___ > > __ ___ > > ___ > > > > Do You Yahoo!? > > > > Yahoo! Greetings - Send FREE e-cards for every occasion! > > > > > > > > > _ __ > > __ ___ > > __ > > > Why Share? > > > Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / > > > > > 20 GB MO/XFER > > > Instant Activation · $99/Month · Free Setup > > > http://www.pennyhost.com/redirect.cfm?adcode=col dfusionc > > > > > FAQ: http://www.thenetprofits.co.uk/coldfusion/faq > > > Archives: http://www.mail-archive.com/cf-talk@house offusion > > com/ > > > Unsubscribe: http://www.houseoffusion.com/index.cfm ?sideb > > ar=lists > > > > > > ___ _ __ > Dedicated Windows 2000 Server > PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER > Instant Activation · $99/Month · Free Setup > http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona > FAQ: http://www.thenetprofits.co.uk/coldfusion/faq > Archives: http://www.mail-archive.com/cf-talk@houseoffusion com/ > Unsubscribe: http://www.houseoffusion.com/index.cfm?sideb ar=lists > __ Get Your Own Dedicated Windows 2000 Server PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: RE: Inserting a delimited list into a database
and don't forget the semicolon after the SQL statement to seperate the SQL for each iteration of the loop ;-) Bryan Stevenson VP & Director of E-Commerce Development Electric Edge Systems Group Inc. p. 250.920.8830 e. [EMAIL PROTECTED] - Macromedia Associate Partner www.macromedia.com - Vancouver Island ColdFusion Users Group Founder & Director www.cfug-vancouverisland.com - Original Message - From: <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Wednesday, February 27, 2002 2:11 PM Subject: Re: RE: Inserting a delimited list into a database > In addition, if you want to reduce your database calls, you can alway > s > > do: > > > > > INSERT INTO [update] (log_id, server) > VALUES (#logQuery.id#,#ServerID#) > > > > That way, you're only doing one db call, that has multiple statemen > ts > > within it. > > Also, you should wrap the dynamic variables in the insert statement > > with tags. > > - Original Message - > From: Matthew Walker <[EMAIL PROTECTED]> > Date: Wednesday, February 27, 2002 3:07 pm > Subject: RE: Inserting a delimited list into a database > > > Hey ho! The problem is having a table called Update! Try wrapping > > > [] around > > update. > > > > > > -----Original Message----- > > > From: Jake Munson [mailto:[EMAIL PROTECTED]] > > > Sent: Thursday, 28 February 2002 10:47 am > > > To: CF-Talk > > > Subject: Inserting a delimited list into a database > > > > > > > > > I have a form that returns a comma delimited list of > > > numbers from some checkboxes that each have the same name. > > > I want to be able to insert a new record in a database for > > > each checkbox that was checked in my form. I figured that > > > if I used a list loop based on my checkbox list, that I > > > could have a SQL query insert a record for each value in > > > the list. But it keeps giving me an error on the insert > > > query. Is it not possible to put a cfquery into a loop? > > > Is there a better way to do this? Below is my code. Below > > > that is the error I get. > > > > > > ITER=","> > > > > > > INSERT INTO update (log_id, server) > > > VALUES (#logQuery.id#,#ServerID#) > > > > > > > > > > > > "[Microsoft][ODBC Microsoft Access Driver] Syntax error > in > > > INSERT INTO statement. > > > > > > The error occurred while processing an element with a > > > general identifier of (CFQUERY), occupying document > > > position..." > > > > > > I thought that maybe the problem was that I didn't have a > > > cfoutput around the #ServerID#, but that wasn't the probl > em > > > either. > > > > > > Thanks for the help. > > > > > > -Jake > > > > > > __ > _ > ___ > > > Do You Yahoo!? > > > Yahoo! Greetings - Send FREE e-cards for every occasion! > > > > > > ___ > _ > __ > > Why Share? > > Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / > > > 20 GB MO/XFER > > Instant Activation · $99/Month · Free Setup > > http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc > > > FAQ: http://www.thenetprofits.co.uk/coldfusion/faq > > Archives: http://www.mail-archive.com/cf-talk@houseoffusion > com/ > > Unsubscribe: http://www.houseoffusion.com/index.cfm?sideb > ar=lists > > > __ Dedicated Windows 2000 Server PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: RE: Inserting a delimited list into a database
In addition, if you want to reduce your database calls, you can alway s do: INSERT INTO [update] (log_id, server) VALUES (#logQuery.id#,#ServerID#) That way, you're only doing one db call, that has multiple statemen ts within it. Also, you should wrap the dynamic variables in the insert statement with tags. - Original Message - From: Matthew Walker <[EMAIL PROTECTED]> Date: Wednesday, February 27, 2002 3:07 pm Subject: RE: Inserting a delimited list into a database > Hey ho! The problem is having a table called Update! Try wrapping > [] around > update. > > > -Original Message- > > From: Jake Munson [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, 28 February 2002 10:47 am > > To: CF-Talk > > Subject: Inserting a delimited list into a database > > > > > > I have a form that returns a comma delimited list of > > numbers from some checkboxes that each have the same name. > > I want to be able to insert a new record in a database for > > each checkbox that was checked in my form. I figured that > > if I used a list loop based on my checkbox list, that I > > could have a SQL query insert a record for each value in > > the list. But it keeps giving me an error on the insert > > query. Is it not possible to put a cfquery into a loop? > > Is there a better way to do this? Below is my code. Below > > that is the error I get. > > > > > > > > INSERT INTO update (log_id, server) > > VALUES (#logQuery.id#,#ServerID#) > > > > > > > > "[Microsoft][ODBC Microsoft Access Driver] Syntax error in > > INSERT INTO statement. > > > > The error occurred while processing an element with a > > general identifier of (CFQUERY), occupying document > > position..." > > > > I thought that maybe the problem was that I didn't have a > > cfoutput around the #ServerID#, but that wasn't the probl em > > either. > > > > Thanks for the help. > > > > -Jake > > > > __ _ ___ > > Do You Yahoo!? > > Yahoo! Greetings - Send FREE e-cards for every occasion! > > > ___ _ __ > Why Share? > Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / > 20 GB MO/XFER > Instant Activation · $99/Month · Free Setup > http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc > FAQ: http://www.thenetprofits.co.uk/coldfusion/faq > Archives: http://www.mail-archive.com/cf-talk@houseoffusion com/ > Unsubscribe: http://www.houseoffusion.com/index.cfm?sideb ar=lists > __ Get Your Own Dedicated Windows 2000 Server PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Inserting a delimited list into a database
Hey ho! The problem is having a table called Update! Try wrapping [] around update. > -Original Message- > From: Jake Munson [mailto:[EMAIL PROTECTED]] > Sent: Thursday, 28 February 2002 10:47 am > To: CF-Talk > Subject: Inserting a delimited list into a database > > > I have a form that returns a comma delimited list of > numbers from some checkboxes that each have the same name. > I want to be able to insert a new record in a database for > each checkbox that was checked in my form. I figured that > if I used a list loop based on my checkbox list, that I > could have a SQL query insert a record for each value in > the list. But it keeps giving me an error on the insert > query. Is it not possible to put a cfquery into a loop? > Is there a better way to do this? Below is my code. Below > that is the error I get. > > > > INSERT INTO update (log_id, server) > VALUES (#logQuery.id#,#ServerID#) > > > > "[Microsoft][ODBC Microsoft Access Driver] Syntax error in > INSERT INTO statement. > > The error occurred while processing an element with a > general identifier of (CFQUERY), occupying document > position..." > > I thought that maybe the problem was that I didn't have a > cfoutput around the #ServerID#, but that wasn't the problem > either. > > Thanks for the help. > > -Jake > > __ > Do You Yahoo!? > Yahoo! Greetings - Send FREE e-cards for every occasion! > __ Why Share? Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Inserting a delimited list into a database
What data types are log_id, server? They are both numbers, yes? Jerry Johnson >>> [EMAIL PROTECTED] 02/27/02 04:47PM >>> I have a form that returns a comma delimited list of numbers from some checkboxes that each have the same name. I want to be able to insert a new record in a database for each checkbox that was checked in my form. I figured that if I used a list loop based on my checkbox list, that I could have a SQL query insert a record for each value in the list. But it keeps giving me an error on the insert query. Is it not possible to put a cfquery into a loop? Is there a better way to do this? Below is my code. Below that is the error I get. INSERT INTO update (log_id, server) VALUES (#logQuery.id#,#ServerID#) "[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position..." I thought that maybe the problem was that I didn't have a cfoutput around the #ServerID#, but that wasn't the problem either. Thanks for the help. -Jake __ Do You Yahoo!? Yahoo! Greetings - Send FREE e-cards for every occasion! __ Dedicated Windows 2000 Server PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Inserting a delimited list into a database
The first thing I would do is dump the FORM.servers variable and make sure that you have all numbers in there. #FORM.servers# <-- ghetto debugging :) _ steve oliver senior internet developer atnet solutions, inc. http://www.atnetsolutions.com -Original Message- From: Jake Munson [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 27, 2002 4:47 PM To: CF-Talk Subject: Inserting a delimited list into a database I have a form that returns a comma delimited list of numbers from some checkboxes that each have the same name. I want to be able to insert a new record in a database for each checkbox that was checked in my form. I figured that if I used a list loop based on my checkbox list, that I could have a SQL query insert a record for each value in the list. But it keeps giving me an error on the insert query. Is it not possible to put a cfquery into a loop? Is there a better way to do this? Below is my code. Below that is the error I get. INSERT INTO update (log_id, server) VALUES (#logQuery.id#,#ServerID#) "[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position..." I thought that maybe the problem was that I didn't have a cfoutput around the #ServerID#, but that wasn't the problem either. Thanks for the help. -Jake __ Do You Yahoo!? Yahoo! Greetings - Send FREE e-cards for every occasion! __ Why Share? Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Inserting a delimited list into a database
Oh yeah... In sql server... Just pass the comma-delimited list to sql server and use this to parse it. Way less calls to the database... -Original Message- From: Costas Piliotis Sent: Wednesday, February 27, 2002 1:49 PM To: '[EMAIL PROTECTED]' Subject: RE: Inserting a delimited list into a database Here's the function to parse a comma-delimited string: CREATE FUNCTION dbo.fnc_ParseDelimited ( @delimitedList VarChar(8000) ) RETURNS @tblSample TABLE (CounterID Int, FieldValue Varchar(100)) BEGIN Declare@CounterID VarChar(4) Declare@FieldValue Varchar(100) Declare @tmpTable Table (CounterID Int Primary Key, FieldValue VarChar(100)) Set @CounterID = 1 While CharIndex(',', @delimitedList) > 0 Begin Set @FieldValue = LTrim(RTrim(subString(@delimitedList, 1, charIndex(',', @delimitedList)-1))) Insert Into @tmpTable Select @CounterID, @FieldValue Set @delimitedList = LTrim(RTrim(subString(@delimitedList, (charIndex(',', @delimitedList) + 1), Len(@delimitedList Set @CounterID = @CounterID + 1 End If LTrim(RTrim(@delimitedList)) != '' Insert Into @tmpTable Select @CounterID, @delimitedList Insert Into @tblSample Select * From @tmpTable Return END -Original Message- From: Jake Munson [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 27, 2002 1:47 PM To: CF-Talk Subject: Inserting a delimited list into a database I have a form that returns a comma delimited list of numbers from some checkboxes that each have the same name. I want to be able to insert a new record in a database for each checkbox that was checked in my form. I figured that if I used a list loop based on my checkbox list, that I could have a SQL query insert a record for each value in the list. But it keeps giving me an error on the insert query. Is it not possible to put a cfquery into a loop? Is there a better way to do this? Below is my code. Below that is the error I get. INSERT INTO update (log_id, server) VALUES (#logQuery.id#,#ServerID#) "[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position..." I thought that maybe the problem was that I didn't have a cfoutput around the #ServerID#, but that wasn't the problem either. Thanks for the help. -Jake __ Do You Yahoo!? Yahoo! Greetings - Send FREE e-cards for every occasion! __ Why Share? Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Inserting a delimited list into a database
Here's the function to parse a comma-delimited string: CREATE FUNCTION dbo.fnc_ParseDelimited ( @delimitedList VarChar(8000) ) RETURNS @tblSample TABLE (CounterID Int, FieldValue Varchar(100)) BEGIN Declare@CounterID VarChar(4) Declare@FieldValue Varchar(100) Declare @tmpTable Table (CounterID Int Primary Key, FieldValue VarChar(100)) Set @CounterID = 1 While CharIndex(',', @delimitedList) > 0 Begin Set @FieldValue = LTrim(RTrim(subString(@delimitedList, 1, charIndex(',', @delimitedList)-1))) Insert Into @tmpTable Select @CounterID, @FieldValue Set @delimitedList = LTrim(RTrim(subString(@delimitedList, (charIndex(',', @delimitedList) + 1), Len(@delimitedList Set @CounterID = @CounterID + 1 End If LTrim(RTrim(@delimitedList)) != '' Insert Into @tmpTable Select @CounterID, @delimitedList Insert Into @tblSample Select * From @tmpTable Return END -Original Message- From: Jake Munson [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 27, 2002 1:47 PM To: CF-Talk Subject: Inserting a delimited list into a database I have a form that returns a comma delimited list of numbers from some checkboxes that each have the same name. I want to be able to insert a new record in a database for each checkbox that was checked in my form. I figured that if I used a list loop based on my checkbox list, that I could have a SQL query insert a record for each value in the list. But it keeps giving me an error on the insert query. Is it not possible to put a cfquery into a loop? Is there a better way to do this? Below is my code. Below that is the error I get. INSERT INTO update (log_id, server) VALUES (#logQuery.id#,#ServerID#) "[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position..." I thought that maybe the problem was that I didn't have a cfoutput around the #ServerID#, but that wasn't the problem either. Thanks for the help. -Jake __ Do You Yahoo!? Yahoo! Greetings - Send FREE e-cards for every occasion! __ Why Share? Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Inserting a delimited list into a database
I have a form that returns a comma delimited list of numbers from some checkboxes that each have the same name. I want to be able to insert a new record in a database for each checkbox that was checked in my form. I figured that if I used a list loop based on my checkbox list, that I could have a SQL query insert a record for each value in the list. But it keeps giving me an error on the insert query. Is it not possible to put a cfquery into a loop? Is there a better way to do this? Below is my code. Below that is the error I get. INSERT INTO update (log_id, server) VALUES (#logQuery.id#,#ServerID#) "[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position..." I thought that maybe the problem was that I didn't have a cfoutput around the #ServerID#, but that wasn't the problem either. Thanks for the help. -Jake __ Do You Yahoo!? Yahoo! Greetings - Send FREE e-cards for every occasion! __ Get Your Own Dedicated Windows 2000 Server PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists