Using queryExecute is probably the best way to go here. While I usually pass the queryparams as a struct in this case since you have a dynamic number of params I would pass them as an array, something like this: sql = "INSERT INTO Contacts (First, Last, Email, Subject, Description)"; params = []; if ( trim(form.type) == 1 ) { sql &= "VALUES(?,?,?,?,?)"; params.append( { maxlength=50, cfsqltype="cf_sql_varchar", value=trim(form.first) } ); params.append( { maxlength=50, cfsqltype="cf_sql_varchar", value=trim(form.last) } ); //etc... } else { //etc... } insertRec = queryExecute(sql, params, {datasource="db" result="qryInsert"});
... View more