简体   繁体   中英

How to update on node js using sqlite3?

I would like to ask how to update on sqlite3 node js, the first function is working (views the data in the HTML from the database), my problem is how to update it. Thanks!

 exports.post = function(req, res){ var id = JSON.stringify(req.body.id); var inputData = [req.body.GIVENNAME, req.body.SURNAME, id]; db.run("UPDATE f11 SET GIVENNAME=$GIVENNAME, SURNAME=? WHERE id=?",inputData, { $GIVENNAME : GIVENNAME, $SURNAME : SURNAME, }); res.redirect("/legone/survey/surveyform/form11"); }; 

Update :

You can try running your query like this:

var inputData = [req.body.GIVENNAME, req.body.SURNAME, id];

db.run("UPDATE f11 SET GIVENNAME=?, SURNAME=? WHERE id=?",inputData,function(err,rows){
    ....
});

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM