>>1, read Ben Forta's "To # or not to #"

Where is that located?  Thanks,

djm


-----Original Message-----
From: Philip Arnold - ASP [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 15, 2001 10:57 AM
To: CF-Talk
Subject: RE: Insert Into Query Bombing Out - What Am I Not Seeing?


> This should be an easy one and I'm a bit embarassed to ask about
> it, but I'm not seeing something.
>
> I want to loop over a list of numbers and do a query Insert Into for each
> item in the list. This is what I have:
>
> (Form.GroupList is a list of numbers, e.g., 5,7,6,3,8,2,1,4)
>
> <cfset Counter = 0>
> <cfloop list="#Form.GroupList#" index="i">
>   <cfset Counter = #counter# + 1>
>   <cfquery name="AddMessage#counter#" datasource="operoutcry">
>     insert into Messages (ListID, From, Subject, MsgBody)
>     values(#Val(i)#, '#form.from#', '#form.subject#', '#form.msgbody#')
>   </cfquery>
> </cfloop>
>
> (the form.from, form.subject, and form.msgbody fields will be the same for
> each insertion)

1, read Ben Forta's "To # or not to #"
2, why are you naming the queries? There's no return, so no reason to name
3, is ListID an AutoNumber? If so, you can't insert into it
4, if "i" is a value, why are you using Val(i) - it'll slow the server up
some
5, ensure that your fields don't have apostrophies in them by using
Replace(form.field,"'","''","all") - SQL will spit otherwise


> I'm getting a syntax error:
>
> Diagnostic error message: ODBC Error Code = 37000 (Syntax error or access
> violation)
>
> [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO
> statement.
>
> SQL = "insert into Messages (ListID, From, Subject, MsgBody)
> values(5, 'Joe Blow', 'Test', 'enter email message here this is a test')"
>
> Using MS Access to do this. What am I not seeing?

Access is nice with it's error messages - they're vague as hell!

Philip Arnold
Director
Certified ColdFusion Developer
ASP Multimedia Limited
T: +44 (0)20 8680 1133

"Websites for the real world"

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to