• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFQUERYPARAM

Engaged ,
May 18, 2013 May 18, 2013

Copy link to clipboard

Copied

I would like to use user input as CFQUERYPARAM for example,

I have txtMyID on the form and would like to use user input as my query parameter.

I tried to use

  <cfqueryparam value = "#trim(form.txtMyID)#" CFSQLTYPE = "cf_sql_integer">

  but does not work,

 

I tried the following which works, but I need get the value from user enter.

  <CFSET MyID = "1">

  <cfqueryparam value = "#MyID#" CFSQLTYPE = "cf_sql_integer">

Your help and information is great appreciated,

Regards,

Iccsi

Views

654

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 18, 2013 May 18, 2013

Copy link to clipboard

Copied

Can you see if cf_sql_numeric works as the type?  I've had problems with integer before.  Also, make sure the data type of your column matches whatever your CFSQLTYPE is.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 20, 2013 May 20, 2013

Copy link to clipboard

Copied

The problem is likely with the value of trim(form.txtMyID). Directly using FORM variables is not a good idea, for a variety of reasons. It is better to initialize all your variables as uniquely named local page variables, and then assign values from FORM or other inputs after validating them.

<cfset ThistxtMyID = "0">

<cfif IsDefined("FORM.txtMyID") AND IsValid("integer", Trim(FORM.txtMyID)>

    <cfset ThistxtMyID = Trim(FORM.txtMyID)>

</cfif>

Be sure to validate ThistxtMyID before you try to use it:

<cfif ThistxtMyID EQ "0">

handle this error condition, don't query the database

</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 20, 2013 May 20, 2013

Copy link to clipboard

Copied

LATEST

Thanks a million for the information and help,

regards,

iccsi,

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation