Question

I have a bunch of data in an array that I want to insert into websql. To do this I have tried the following but it just crashs the browser...

  while (i != data_lines)
   {
   db.transaction(function (tx) 
   {
   tx.executeSql('INSERT INTO  ' + tablename + ' (column1 column2. column3) VALUES (?, ?, ?)',[arrData[i][0],arrData[i][1],arrData[i][2]],
   i++)
   });
   }

As well as...

   while (i != data_lines)
   {
   i++
   db.transaction(function (tx) 
   {
   tx.executeSql('INSERT INTO  ' + tablename + ' (column1 column2. column3) VALUES (?, ?, ?)',[arrData[i][0],arrData[i][1],arrData[i][2]])
   });
   }

In this example i is set to the maximum record without iterating through. What would be the best method to perform this?

Was it helpful?

Solution

Loop over request

db.transaction(function (tx) {
while (i != data_lines) {
     i++
       tx.executeSql('INSERT INTO  ' + tablename + ' (column1 column2. column3) VALUES (?, ?, ?)',[arrData[i][0],arrData[i][1],arrData[i][2]])
     });
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top