Not to one up Doug, but a good practice after his suggestion is also to put
in a maxlength on cfqueryparam to the maxlength of the data columns you are
referring to.
If the maxlength for the SKU column is a varchar(40), then:
<cfquery name="product" datasource="carbs">
SELECT Description1, Description2, Vend_Name
FROM carbs.products
WHERE sku = <cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.sku#"
maxlength="40" />
</cfquery>
This is an added check on strings to prevent large strings inadvertantly.
The maxlength is for strings and not for numbers.
Teddy
On 3/9/07, Douglas Knudsen <[EMAIL PROTECTED]> wrote:
RIght after
<cfquery name="product" datasource="carbs">
SELECT Description1, Description2, Vend_Name
FROM carbs.products
WHERE sku = '#FORM.sku#'
</cfquery>
try adding this for testing purposes
<cfdump var="#product#" /><cfabort />
Also, others may jump on this before I, really should use cfqueryparam
<cfquery name="product" datasource="carbs">
SELECT Description1, Description2, Vend_Name
FROM carbs.products
WHERE sku = <cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.sku#" />
</cfquery>
Ask Charlie all about the null attribute :)
DK
On 3/8/07, Robert Reil <[EMAIL PROTECTED]> wrote:
>
> thanks doug. I tired the products.name but still did not work. Im
> tired. Bed time.
>
> MY DAY IN 1.5 hrs u know!!!!!!
> I think u see it coming too!!!!
>
>
> Robert P. Reil
>
> Managing Director,
>
> Motorcyclecarbs.com <http://motorcyclecarbs.com/>, Inc.
>
> 4292 Country Garden Walk NW
>
> Kennesaw, Ga. 30152
>
> Office 770-974-8851
>
> Fax 770-974-8852
>
> www.motorcyclecarbs.com
>
>
> ------------------------------
> *From:* Douglas Knudsen [mailto:[EMAIL PROTECTED]
> *Sent:* Thursday, March 08, 2007 9:51 PM
> *To:* Carbs Sales&Service
> *Subject:* Re: [ACFUG Discuss] CFQuery Basics: HELP!
>
>
> hey, its 2 hours away to your Friday!
>
> Ok, first off, from the looks of it you are assuming you will always get
> one record from this SQL, with your data this maybe a fair assumption, but
> be careful of assumptions, they'll bite you someday in code. I'm living
> proof carrying many scars from the code dog.
>
> Now, a couple things with this line:
> <cfset desc1 = #Description1#>
>
> 1) You should always scope your variables, a few rare cases where you
> may not want to, but this is definitely not one of them. So change the line
> to
> <cfset desc1 = #product.Description1# />
> 2) # use, you do not need pounds inside tags and functions unless you
> are inside quotes, so change the above to
> <cfset desc1 = product.Description1 />
> 3) Are you always 100% sure your SQL will return at least one row? I'm
> guessing in this case it is not. So, need to wrap your line above in a
> check for this
> <cfif product.recordcount GTE 1>
> <cfset desc1 = product.Description1 />
> </cfif>
>
> That said, I'd urge you to use CFOUTPUT and its QUERY attribute, then
> you can write code not worrying about 1 so much, depending on your situation
> of course. This would lead you to something like the below. With this, no
> need to use the cfset lines you have and this will work when the SQL has no
> records returned. Note also if the SQL returns more than one record, the
> cfoutput will loop over all of them for you.
>
> <cfoutput query="product">
> <tr bgcolor="##cccccc">
> <td><strong>: #form.sku# </strong> <br>
> #product.Desc1#
> </td>
> <td>#product.Vend_Name#</td>
> </tr>
> <tr>
> <td colspan="2">
> <font size="-2">#product.Description2#</font>
>
> > </td>
> > </tr>
> > </cfoutput>
>
>
>
> HTH!
>
> DK
>
> On 3/8/07, Robert Reil < [EMAIL PROTECTED]> wrote:
> >
> > Well we got somewhere in the WACK group tonight but did not quite
> > reach the
> > goal. I have a small problem with the following file, can anyone help
> > me
> > figure out what is wrong with my call for my descriptions and vend
> > name?
> >
> > ------------------------------
> > <cfquery name="product" datasource="carbs">
> > SELECT Description1, Description2, Vend_Name
> > FROM carbs.products
> > WHERE sku = '#FORM.sku#'
> > </cfquery>
> > <html>
> > <head>
> > <title>Product Search Results</title>
> > </head>
> > <body>
> > <cfset desc1 = #Description1#>
> > <cfset desc2 = #Description2#>
> > <cfset vendor = #Vend_Name#>
> >
> > <!--- Display search text --->
> > <cfoutput>
> > <strong>SKU:</strong>
> > <table>
> > <tr>
> > <th colspan="2">
> > <font size="+2">
> > Products
> > </font>
> > </th>
> > </tr>
> > <cfoutput>
> > <tr bgcolor="##cccccc">
> > <td>
> > <strong>:
> > #sku#
> > </strong>
> > <br>
> > #Desc1#
> > </td>
> > <td>
> > #Vend_Name#
> > </td>
> > </tr>
> > <tr>
> > <td colspan="2">
> > <font size="-2">#Description2#</font>
> > </td>
> > </tr>
> > </cfoutput>
> > </table>
> > </cfoutput>
> > </body>
> > </html>
> >
> > -----------------------------
> > Problem is that it gets stuck at:
> > Variable DESCRIPTION1 is undefined.
> >
> > The error occurred in
> > C:\Inetpub\wwwroot\intranet.motorcyclecarbs.com\sales\form1_action.cfm:
> > line
> > 20
> >
> > 18 : <body>
> > 19 : <cfset sku=#form.sku#>
> > 20 : <cfset desc1 = #Description1#>
> > 21 : <cfset desc2 = #Description2#>
> > 22 : <cfset vendor = #Vend_Name#>
> >
> >
> >
> >
> > -------------------------------------------------------------
> > To unsubscribe from this list, manage your profile @
> > http://www.acfug.org?fa=login.edituserform
> > <http://www.acfug.org/?fa=login.edituserform>
> >
> > For more info, see http://www.acfug.org/mailinglists
> > Archive @ http://www.mail-archive.com/discussion%40acfug.org/
> > List hosted by http://www.fusionlink.com
> > -------------------------------------------------------------
> >
> >
> >
> >
>
>
> --
> Douglas Knudsen
> http://www.cubicleman.com
> this is my signature, like it?
> -------------------------------------------------------------
> To unsubscribe from this list, manage your profile @
> http://www.acfug.org?fa=login.edituserform
> <http://www.acfug.org/?fa=login.edituserform>
>
> For more info, see http://www.acfug.org/mailinglists
> Archive @ http://www.mail-archive.com/discussion%40acfug.org/
> List hosted by FusionLink <http://www.fusionlink.com/>
> -------------------------------------------------------------
>
--
Douglas Knudsen
http://www.cubicleman.com
this is my signature, like it?
-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform<http://www.acfug.org/?fa=login.edituserform>
For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by FusionLink <http://www.fusionlink.com/>
-------------------------------------------------------------
--
Teddy R. Payne
G-Talk: [EMAIL PROTECTED]
Adobe Certified ColdFusion MX 7 Developer
Atlanta ColdFusion User Group (ACFUG)
Atlanta Flash & Flex User Group (AFFUG)
-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform
For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------