Suddenly can't populate a field with CF INSERT

New Here ,
Oct 31, 2020 Oct 31, 2020

Copy link to clipboard

Copied

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

Views

53

Likes

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
Adobe Community Professional ,
Nov 03, 2020 Nov 03, 2020

Copy link to clipboard

Copied

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>

 

 

Likes

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
New Here ,
Nov 03, 2020 Nov 03, 2020

Copy link to clipboard

Copied

LATEST
Thanks! I'll give it a try.

-Dale

Likes

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