8 Replies Latest reply on Feb 6, 2017 8:32 AM by BKBK

    CFSCRIPT queryNew querySetCell: can't seem to query object

    WolfShade Level 4

      Hello, all,

       

      I'm attempting to use (within CFSCRIPT) queryNew() and querySetCell() to create a database object, then use qry.execute() to SELECT data from it.

       

      I have tried many variations, each giving a different error message.  I cannot figure out what I'm missing, and I'm pretty sure it is something really simple.

       

      <CFSCRIPT>
          cities = queryNew('cityID,cityName','varchar,varchar');
          queryAddRow(cities,10);
          querySetCell(cities,'cityID','1',1);    querySetCell(cities,'cityName','New York',1);
              ...
          querySetCell(cities,'cityID','10',10);  querySetCell(cities,'cityName','St. Louis',10);
      
          myQry = new Query();
          myQry.setSQL("SELECT cityID, cityName FROM cities");
          myQry.setDatasource('cities');
          qryRes = myQry.execute();
          return qryRes;
      </CFSCRIPT>
      

       

      The above is within a CFC function.  The result currently is: "Datasource 'cities' could not be found."

       

      I've never tried this in CFSCRIPT, before, so I'm in totally new territory.  Any thoughts on what I'm doing incorrectly?

       

      V/r,

       

      ^_^