clint
clint

Reputation: 1956

Phonegap insert query + not working

I am using phoneagap framework for APP development. Insert query in phonegap:

tx.executeSql('insert into "'+gAppConfig.configTable+'" (key , value) values(uniqueId,"'+uniqueId+'"),(serverURL,"'+serverURL+'")' , querySuccess, errorQuery);

This is not working, Can anybody tell me what could be wrong. Thanks.

Upvotes: 0

Views: 598

Answers (1)

T.Baba
T.Baba

Reputation: 649

I suppose that you've created a table in the database, and you've named it "tablename" with 2 columns "id" & "serverURL"; where "id" is the primary key.

Try this:

   Iquery = "INSERT INTO 'tableName' VALUES(null, "+serverURL+");";
   tx.executeSql(
      Iquery,
      null,
      function(){ /* to do on success, or you may just set it as "null" */},
      function(){ /* to do on error, or you may just set it as "null" */});

or you may try this:

 tx.executeSql("INSERT INTO tableName(id, serverURL) VALUES (?,?)",
        [null, serverURL], // these are the variables to insert
        function(){ /* to do on success, or you may just set it as "null" */},
        function(){ /* to do on fail, or you may just set it as "null" */});

you may refer to the original documentation of cordova for more info.

Upvotes: 1

Related Questions