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

Looking for CFGRID & CFGRIDUPDATE Examples

Status
Not open for further replies.

spook007

Programmer
May 22, 2002
259
US
I've Macromedia's cfgrid & cfgridupdate examples, but they are useless as they don't provide you with the full code. Does anyone know of where I can find examples on how to use this code. I've tried updating my DB using the following, but I get the following error when using cfgridupdate.

[Macromedia][SQLServer JDBC Driver][SQLServer]The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.

The SQL that CF generated automatically looks like this:

update inspectionTest set Inspection = (param 1) , Actual = (param 2) where ID = (param 3) and Inspection = (param 4) and Actual = (param 5)

Any suggestions are welcomed!!
 
How about this:

Code:
<!--- We are submitting some changes - how many changes were made? --->
<cfset NumChanges = ArrayLen(FORM.GridData.RowStatus.Action)>

<!---
	We will need to loop through this array twice
	First pass will handle all deletes.  This updates Row numbers (needed for error messages in Updates)
<cfloop FROM="1" TO="#NumChanges#" INDEX="idx">
	<cfif (UCASE(FORM.GridData.RowStatus.Action[idx]) EQ "D")>
		<cfset line_id = FORM.GridData.ORIGINAL.LINE_ID[idx]>
		<cfinclude template="#_Exhibits.QueryRoot#/qry_D44_NumbersDelete.cfm">
	</cfif>
</cfloop>
 --->

<!--- Now we can process all Inserts and Updates --->
<cfloop FROM="1" TO="#NumChanges#" INDEX="idx">
	<!--- If we are Inserting or Updating, validate the data --->
	<cfif ListFindNoCase("I,U", FORM.GridData.RowStatus.Action[idx])>

		<cfset fp_id = FORM.GridData.PEC_ID[idx]>
		<cfset row_id = FORM.GridData.PEC_ID[idx]>
		<cfset pec_id = FORM.GridData.PEC_ID[idx]>
		<cfset eeic_id = FORM.GridData.EEIC_ID[idx]>
		<cfset pfy_am = FORM.GridData.PFY_AM[idx]>
		<cfset cfy_am = FORM.GridData.CFY_AM[idx]>
		<cfset fpy_am = FORM.GridData.FPY_AM[idx]>
		<cfset fy1_am = FORM.GridData.FY1_AM[idx]>
		<cfset fy2_am = FORM.GridData.FY2_AM[idx]>
		<cfset fy3_am = FORM.GridData.FY3_AM[idx]>
		<cfset fy4_am = FORM.GridData.FY4_AM[idx]>
		<cfset fy5_am = FORM.GridData.FY5_AM[idx]>

		<!--- Default the number fields if left blank --->
		<cfscript>
			if (Len(pfy_am) EQ 0) pfy_am = 0;
			if (Len(cfy_am) EQ 0) cfy_am = 0;
			if (Len(fpy_am) EQ 0) fpy_am = 0;
			if (Len(fy1_am) EQ 0) fy1_am = 0;
			if (Len(fy2_am) EQ 0) fy2_am = 0;
			if (Len(fy3_am) EQ 0) fy3_am = 0;
			if (Len(fy4_am) EQ 0) fy4_am = 0;
			if (Len(fy5_am) EQ 0) fy5_am = 0;
		</cfscript>

		<cfset RSet = "GridUpdate">
		<cfinclude template="#_Exhibits.QueryRoot#/qry_D44_NumbersUpdate.cfm">
		<cfset errMessage = GridUpdate.ERROR_TX>

This will loop through all changes made to the grid and include appropriate qry files to handle the updates.

You can just replace the cfincludes with actual DML if you prefer.

Hope this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top