Copy link to clipboard
Copied
I am not able to get <cfinsert> to work to insert into a remote DB2 database. I have been able to get cfquery INSERT's to insert into the DB2 database. I have not been able to get radio button data to INSERT into this database.
This is what I have tried:
___________________________________________________
surveyForm.cfm:
<html>
<head>
<title>Survey Form</title>
</head>
<body>
<h2>Enter a Survey Form</h2>
<cfform action="surveyAction.cfm" method="post">
Branch:
<cfinput type="text" name="BRANCH" size="4" maxlength="4"><br><br>
Contact Name:
<cfinput type="text" name="CONTACT_NAME" size="40" maxlength="40"><br><br>
Did you get what you needed today?  
<cfinput type="radio" name="NEED_FLAG" id="radio" value="Y">Yes
<cfinput type="radio" name="NEED_FLAG" id="radio" value="N">No
<cfinput type="radio" name="NEED_FLAG" id="radio" value="X">Did Not Answer<br><br>
<br><br>
<input type="Submit" value="Submit"> <input type="Reset"
value="Clear Form"></td>
</cfform>
</body>
</html>
___________________________________________________
surveyAction.cfm:
<html>
<head> <title>Insert Survey Form</title> </head>
<body>
<!--- This works until I add the radio button to the insert --->
<!--- Insert the new record --->
<cfquery datasource="AXMISC_SURVEY">
INSERT INTO SURVEY.CAF_SURVEY
(BRANCH, CONTACT_NAME, NEED_FLAG)
VALUES
( <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.BRANCH#">,
<cfqueryparam cfsqltype="cf_sql_char" value="#form.CONTACT_NAME#">
<cfqueryparam cfsqltype="cf_sql_char" value="#form.NEED_FLAG#">
)
</cfquery>
</body>
</html>
___________________________________________________
Thanks,
Jeanne
zer0Weaver wrote:
<!--- This works until I add the radio button to the insert --->
<!--- Insert the new record ---><cfquery datasource="AXMISC_SURVEY">
INSERT INTO SURVEY.CAF_SURVEY
(BRANCH, CONTACT_NAME, NEED_FLAG)
VALUES
( <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.BRANCH#">,
<cfqueryparam cfsqltype="cf_sql_char" value="#form.CONTACT_NAME#">
<cfqueryparam cfsqltype="cf_sql_char" value="#form.NEED_FLAG#">
)
</cfquery></body>
</html>
Hi Jeanne,
Thanks for posting the rel
...Copy link to clipboard
Copied
zer0Weaver wrote:
<!--- This works until I add the radio button to the insert --->
<!--- Insert the new record ---><cfquery datasource="AXMISC_SURVEY">
INSERT INTO SURVEY.CAF_SURVEY
(BRANCH, CONTACT_NAME, NEED_FLAG)
VALUES
( <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.BRANCH#">,
<cfqueryparam cfsqltype="cf_sql_char" value="#form.CONTACT_NAME#">
<cfqueryparam cfsqltype="cf_sql_char" value="#form.NEED_FLAG#">
)
</cfquery></body>
</html>
Hi Jeanne,
Thanks for posting the relevant information, but you forgot to mention what _is_ happening now 😉 Does an error occur, and if so what is the error message, etcetera.. ? But my guess would be you are missing a comma in the VALUES (...) clause:
VALUES
(
<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.BRANCH#"> ,
<cfqueryparam cfsqltype="cf_sql_char" value="#form.CONTACT_NAME#"> , <!--- should be a comma here --->
<cfqueryparam cfsqltype="cf_sql_char" value="#form.NEED_FLAG#">
)
Copy link to clipboard
Copied
Also, radio buttons only exist if they were checked. So you should verify the fields exists before using it, or define a default values with cfparam
<cfparam name="form.NEED_FLAG" default="YourDefaultValueHere">
Copy link to clipboard
Copied
That was it! Thanks