7 Replies Latest reply on Apr 24, 2011 2:17 PM by Lee Burrows

    problem with a sqlite update statement using variables

    Kristin95762 Level 1

      Flash Builder/Flex 4

       

      I'm trying to create a routine that will allow me to change the name of an author in a sqlite table.

       

      I have this update statement which works with hardcoded data:

       

      //trace("updateName function newAuthorName: " + newAuthorName (returns Dusty));

      //trace("updateName function oldAuthorName: " + oldAuthorName (returns Kristin));

       

      updateStmt = new SQLStatement();

      updateStmt.sqlConnection = conn;

       

      var sql:String = "UPDATE tableName SET authorNameColumn = 'Dusty' WHERE authorNameColumn = 'Kristin' ";

       

      updateStmt.text = sql;

       

       

       

      updateStmt.execute();

       

      If I change the statement to

       

      "UPDATE tableName SET authorNameColumn  =" +  newAuthorName +  "WHERE authorNameColumn =" + oldAuthorName;

      I get SELECT error: SQLError: 'Error #3115: SQL Error.', details:'near 'authorNameColumn': syntax error'

       

      I've tried changing many things about this statement trying to isolate the problem, but it seems to not like the variables.