Databse in electron


#1

in my app the print preview is generated just after the save query, but the data is not saved in the database. i checked my query but i cant find anything wrong. how is it possible to overcome this issue? i tried delay between save and preview generating then its working. Is it a right method? if not please guide me?


#2

do you mind sharing your code for DB query? that way we can help otherwise we are clueless at what going wrong


#3

thanks for your minding, i fixed it


#4

Then you should tell the forum how you fixed to help someone who will have a similar problem


#5

my query is fine from the beginning.

db.serialize(function() {
                db.run("INSERT INTO service_inventory ('job_date','job_no','cust_name','cust_address','cust_contact_no','product','brand','model','serial_no','issues','parts_recieved','delivery_date','amount_to_pay','advance_amount','status','technician','issued_by') VALUES ('" + job_date + "','" + jobno + "','" + customer + "','" + address + "','" + contact + "','" + product + "','" + brand + "','" + model + "','" + serialno + "','" + issue + "','" + selchbox + "','" + delivery_date + "','" + servicecharge + "','" + advanceamount + "','" + status + "','" + technician + "','" + issuedby + "')"

this what i did , but when i run this code executed but data is not saved in the db. with a little help from my senior i added this along with this

    db.serialize(function() {
                    db.run("INSERT INTO service_inventory ('job_date','job_no','cust_name','cust_address','cust_contact_no','product','brand','model','serial_no','issues','parts_recieved','delivery_date','amount_to_pay','advance_amount','status','technician','issued_by') VALUES ('" + job_date + "','" + jobno + "','" + customer + "','" + address + "','" + contact + "','" + product + "','" + brand + "','" + model + "','" + serialno + "','" + issue + "','" + selchbox + "','" + delivery_date + "','" + servicecharge + "','" + advanceamount + "','" + status + "','" + technician + "','" + issuedby + "')", function (error){                  
if(error)
                            {
                                throw error;
                            }
                        else
                            {
                                code to execute..
                            }
                    });
                });

And now i am working fine all my data is going into the db when i click.