Name

QuerySetCell

Synopsis

QuerySetCell(query, columnname, value [, row])

Sets the cell in columnname to value for the specified query. An optional row number may be set, specifying the row for the cell to be set in. If no row number is specified, the cell in the last row of the query is set. QuerySetCell( ) returns True upon successful completion. Here’s an example that adds data to an empty query:

<CFSET Products = QueryNew("ProductName, Color, Price, Qty")>
<CFSET NewRows  = QueryAddRow(Products, 3)>

<CFSET temp = QuerySetCell(Products, "ProductName", "Widget", 1)>
<CFSET temp = QuerySetCell(Products, "Color", "Silver", 1)>
<CFSET temp = QuerySetCell(Products, "Price", "19.99", 1)>
<CFSET temp = QuerySetCell(Products, "Qty", "46", 1)>

<CFSET temp = QuerySetCell(Products, "ProductName", "Thingy", 2)>
<CFSET temp = QuerySetCell(Products, "Color", "Red", 2)>
<CFSET temp = QuerySetCell(Products, "Price", "34.99", 2)>
<CFSET temp = QuerySetCell(Products, "Qty", "12", 2)>

<CFSET temp = QuerySetCell(Products, "ProductName", "Sprocket", 3)>
<CFSET temp = QuerySetCell(Products, "Color", "Blue", 3)>
<CFSET temp = QuerySetCell(Products, "Price", "1.50", 3)>
<CFSET temp = QuerySetCell(Products, "Qty", "460", 3)>

<TABLE>
  <TR><TH>Product</TH><TH>Color</TH><TH>Price</TH><TH>Quantity</TH></TR>
<CFOUTPUT QUERY="Products">
  <TR><TD>#ProductName#</TD><TD>#Color#</TD><TD>#Price#</TD><TD>#Qty#</TD></TR>
</CFOUTPUT>
</TABLE>

Get Programming ColdFusion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.