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

Suddenly can't populate a field with CF INSERT

New Here ,
Oct 31, 2020 Oct 31, 2020

I have an INSERT command in a CF script to add a record to a data table. There are four fields I am populating. Fields three and four are being populated with the same data. Here’s the code:

        INSERT INTO tblPQMS_Requests

          (

          PQMSReq_By,

          PQMSReq_Status,

          PQMS_Proj,

          ERP_PQMS_Proj

          )

        VALUES

          (

          'LibMgr',

          '1',

          '#htmlEditFormat(projectno)#',

          '#htmlEditFormat(projectno)#'  <!--- Suddenly can't get this field filled! --->

          )

You see my comment on the last line. I can’t get projectno into ERP_PQMS_Proj. In fact, I can’t get ANYTHING into the field named ERP_PQMS_Proj, even if I just try to stick a bit of text into this text field.

 

Furthermore, the procedure worked until a few days ago!

 

I have never experienced this "locked-field syndrome" before and have spent hours trying to figure out what is going on. Any ideas? Thanks!

TOPICS
Database access
146
Translate
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
Community Expert ,
Nov 03, 2020 Nov 03, 2020

Two remarks.

1) HtmlEditFormat has been deprecated. Assuming you have a recent version of ColdFusion, replace it with EncodeForHTML.

2) Use parameter-binding (cfsqltype). If your query fails because of parameter type, then ColdFusion will likely tell you so.

Try something like:

<cfscript>
sqlString="
INSERT INTO tblPQMS_Requests
  (
  PQMSReq_By,
  PQMSReq_Status,
  PQMS_Proj,
  ERP_PQMS_Proj
  )
VALUES
  (
  :PQMSReqBy,
  :PQMSReqStatus,
  :PQMSProj,
  :ERPPQMSProj
  )";

// Bind the parameter types
sqlParameters={
	PQMSReqBy={value='LibMgr', cfsqltype="varchar"},
	PQMSReqStatus={value='1', cfsqltype="varchar"},
	PQMSProj={value='#encodeForHTML(projectno)#' , cfsqltype="varchar"},
	ERPPQMSProj={value='#encodeForHTML(projectno)#' , cfsqltype="varchar"}
}

// insert-query
queryExecute(sqlString, sqlParameters, {datasource="yourDSN"});
</cfscript>

 

 

Translate
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
New Here ,
Nov 03, 2020 Nov 03, 2020
LATEST
Thanks! I'll give it a try.

-Dale
Translate
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