2
        db.transaction(
           function (transaction) {
               transaction.executeSql('INSERT INTO EmployeeTable(Firstname,Lastname,BirthDate,EmployeeType,MaritalStatus,Company,IsActive,Dependents) values(?,?,?,?,?,?,?,?)',
                   [Firstname.toString(), Lastname.toString(), BirthDate, parseInt(empType), parseInt(marital),Company.toString(),active, parseInt(Dependents)]);

               transaction.executeSql('SELECT * FROM EmployeeTable', [], function (transaction, results) {

                   result = results;

                   alert(result.length);

                    for (i = 0; i < results.length; i++) {

                        var EmployeeID = results.rows.item(i).EmployeeID;
                        var Firstname = results.rows.item(i).Firstname;
                        var Lastname = results.rows.item(i).Lastname;

                        alert(results.rows.item(i).EmployeeID + "  " + results.rows.item(i).Firstname + "  " + results.rows.item(i).Lastname);
                        //var product =  [productid, productname, price, qty];                     
                        //insertTableRow(product,i);
                    }




                  }, null);    
           }
         );

am Using WEB SQL as Local Database

want to send data retrived from websql using db.Transaction() method to server controller.

Please Help On same.....

How should i transfer data to controller of mvc.....

    [HttpPost]
    public ActionResult Create(FormCollection collection)
    {
        try
        {

            if (Save(0, collection))
            {
                // List<char> bulkdata = collection["bulkdata"].ToList();
                return RedirectToAction("Index");
            }

            else
            {
                return View("Edit");
            }
        }
        catch
        {
            return View();
        }
    }
tereško
  • 58,060
  • 25
  • 98
  • 150

2 Answers2

0

The following tutorial shows an example how to sync local db with a WCF Data Service endpoint. By combining this with the WebAPI tutorial you will be able to sync to the online DB with these lines:

function synchronizeData() {
        offlinedb
            .TodoItems
            .filter("it.InSync === false")
            .toArray(function (todoItems) {
                onlinedb.addMany(todoItems);
                onlinedb.saveChanges(function () {
                    todoItems.forEach(function (todoItem) {
                        offlinedb.attach(todoItem);
                        todoItem.InSync = true;
                    });
                    offlinedb.saveChanges(function () {
                        listLocalTodoItems();
                        listRemoteTodoItems();
                    });
                });
            })
    }
Robesz
  • 1,646
  • 11
  • 13
0

You might try serializing your localstorage string and then send to the server...

ASP.NET MVC How to pass JSON object from View to Controller as Parameter

Community
  • 1
  • 1
tintyethan
  • 1,772
  • 3
  • 20
  • 44