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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERTING DATA FROM DROPDOWN LIST -- HELP!!

Status
Not open for further replies.

kingjjx

Programmer
Joined
Sep 18, 2001
Messages
181
Location
US
Hi, How do you loop an input from a dropdown list ?
I have a form that has 5 fields for FNAME, 5 for LNAME and 5 dropdown list for year... all this is getting sent at once.

How do I insert this in my database ???
THIS IS WHAT MY CODE LOOKS LIKE AT ITS GIVING ME AN ERROR:

THIS IS THE CODE FOR THE INSERT/ACTION PAGE:
<CFLOOP from=1 to=5 index=&quot;loopcount&quot;>
<CFSET currF=&quot;fname#loopcount#&quot;>
<CFSET currL=&quot;lname#loopcount#&quot;>
<CFSET currY=&quot;year#loopcount#&quot;>
<Cfquery name=&quot;addjcode&quot; datasource=&quot;Timesheets&quot;>
INSERT testdata (Year, Fname, Lname)
VALUES('#evaluate(currY)#', '#evaluate(currF)#', '#evaluate(currL)#')
</cfquery>
</CFLOOP>


 

Code looks pretty good. What is the Error?

If Year is of Type Integer or Real ( not any kind of string ) then you shouldn't use ' around it. Try this:

<CFLOOP from=1 to=5 index=&quot;loopcount&quot;>
<CFSET currF=&quot;fname#loopcount#&quot;>
<CFSET currL=&quot;lname#loopcount#&quot;>
<CFSET currY=&quot;year#loopcount#&quot;>
<Cfquery name=&quot;addjcode&quot; datasource=&quot;Timesheets&quot;>
INSERT testdata (Year, Fname, Lname)
VALUES(#evaluate(currY)# , '#evaluate(currF)#', '#evaluate(currL)#')
</cfquery>
</CFLOOP>

Otherwise let us know what the error is and we'll try again.
 
hi .. it is saying error in the INSERT TO statement.
here it is below :

Error Diagnostic Information
ODBC Error Code = 37000 (Syntax error or access violation)


[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 (6:3) to (6:51).


Date/Time: 01/24/02 14:01:27

 
hey, i guess the error is not just in the dropdown list thingy since i took it out and it still gave me the same error.

any advice where I can start debugging ?

thanks
 
HEY, FINALLY GOT IT TO WORK.

THANKS FOR YOUR HELP DUDE !!
 
Great...

Hey what was it? you got me all curious?
 
hehe ... if you look up in my first post .. I only wrote INSERT tablename .. changed it to INSERT INTO tablename :~/

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top