Answered
Error Executing Database Query
Hello,
I'm getting an "Error Executing Database Query" error when I try to submit a small form I created. Any help I can get would be greatly appreciated.
Here is the CFM code on the form page:
<cfquery name="rsGoldStar" datasource="HRTraining">
SELECT *
FROM dbo.tblEmployees
WHERE Active = 1
ORDER BY LastName ASC</cfquery>
.
.
.
Here is the form code on the form page:
<form action="thanksGS.cfm" id="form1" name="form1" method="POST">
<h3>
</h3>
<table width="68%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td width="100%"><h2><strong>Referred by: </strong></h2></td>
</tr>
<tr>
<td><select name="EmployeeID">
<cfoutput query="rsGoldStar">
<option value="#rsGoldStar.EmployeeID#">#rsGoldStar.LastName#, #rsGoldStar.FirstName#</option>
</cfoutput>
</select>
<strong><span class="style3 style2">(Required)</span></strong></td>
</tr>
</table>
<table width="518" border="0">
<tr>
<td width="177"><h2>Date:</h2></td>
<td width="331"><input name="GoldCardDate" type="text" id="GoldCardDate" size="8" maxlength="8" /></td>
</tr>
<tr>
<td><h2>Applicant Name: </h2></td>
<td><input name="ApplicantName" type="text" id="ApplicantName" size="40" maxlength="50" /></td>
</tr>
<tr>
<td><h2>Position Applying For: </h2></td>
<td><input name="PositionApplyingFor" type="text" id="PositionApplyingFor" size="50" maxlength="75" /></td>
</tr>
</table>
<h2> </h2>
<p><input type="submit" name="Submit" value="submit" />
<label>
<input name="Reset" type="reset" id="Reset" value="Reset" />
</label>
<label></label>
</p>
</form>
________________________
Now here is the action page CFM code:
<cftry>
<cfquery name="insertRow" datasource="HRTraining">
INSERT INTO tblGoldCards (EmployeeID, GoldCardDate, ApplicantName, PositionApplyingFor)
VALUES (<cfqueryparam value = "#form.EmployeeID#" cfsqltype="cf_sql_integer" maxlength="4">, <cfqueryparam value="#form.GoldCardDate#" cfsqltype="cf_sql_date" maxlength="8">, <cfqueryparam value="#form.ApplicantName#" cfsqltype="cf_sql_varchar" maxlength="50">, <cfqueryparam value="#form.PositionApplyingFor#" cfsqltype="cf_sql_varchar" maxlength="75">)
</cfquery>
<!--- If you sign up for a twice ERROR--->
<cfcatch type="database">
<cfif cfcatch.Message CONTAINS " ">
</cfif>
<cfrethrow />
<cfabort>
</cfcatch>
</cftry>
Thank you in advance.
I'm getting an "Error Executing Database Query" error when I try to submit a small form I created. Any help I can get would be greatly appreciated.
Here is the CFM code on the form page:
<cfquery name="rsGoldStar" datasource="HRTraining">
SELECT *
FROM dbo.tblEmployees
WHERE Active = 1
ORDER BY LastName ASC</cfquery>
.
.
.
Here is the form code on the form page:
<form action="thanksGS.cfm" id="form1" name="form1" method="POST">
<h3>
</h3>
<table width="68%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td width="100%"><h2><strong>Referred by: </strong></h2></td>
</tr>
<tr>
<td><select name="EmployeeID">
<cfoutput query="rsGoldStar">
<option value="#rsGoldStar.EmployeeID#">#rsGoldStar.LastName#, #rsGoldStar.FirstName#</option>
</cfoutput>
</select>
<strong><span class="style3 style2">(Required)</span></strong></td>
</tr>
</table>
<table width="518" border="0">
<tr>
<td width="177"><h2>Date:</h2></td>
<td width="331"><input name="GoldCardDate" type="text" id="GoldCardDate" size="8" maxlength="8" /></td>
</tr>
<tr>
<td><h2>Applicant Name: </h2></td>
<td><input name="ApplicantName" type="text" id="ApplicantName" size="40" maxlength="50" /></td>
</tr>
<tr>
<td><h2>Position Applying For: </h2></td>
<td><input name="PositionApplyingFor" type="text" id="PositionApplyingFor" size="50" maxlength="75" /></td>
</tr>
</table>
<h2> </h2>
<p><input type="submit" name="Submit" value="submit" />
<label>
<input name="Reset" type="reset" id="Reset" value="Reset" />
</label>
<label></label>
</p>
</form>
________________________
Now here is the action page CFM code:
<cftry>
<cfquery name="insertRow" datasource="HRTraining">
INSERT INTO tblGoldCards (EmployeeID, GoldCardDate, ApplicantName, PositionApplyingFor)
VALUES (<cfqueryparam value = "#form.EmployeeID#" cfsqltype="cf_sql_integer" maxlength="4">, <cfqueryparam value="#form.GoldCardDate#" cfsqltype="cf_sql_date" maxlength="8">, <cfqueryparam value="#form.ApplicantName#" cfsqltype="cf_sql_varchar" maxlength="50">, <cfqueryparam value="#form.PositionApplyingFor#" cfsqltype="cf_sql_varchar" maxlength="75">)
</cfquery>
<!--- If you sign up for a twice ERROR--->
<cfcatch type="database">
<cfif cfcatch.Message CONTAINS " ">
</cfif>
<cfrethrow />
<cfabort>
</cfcatch>
</cftry>
Thank you in advance.
