Mike Waller
asked on
update query to SQLite database
I'm trying to do an update query from a Zinc textfield component to SQLite database. The following won't work. Any idea what I need to adjust?
on(release)
{
var val = _parent.myDB.runQuery("UPD ATE preferences SET typenum = \""+thisfield.text+"\" WHERE id = 1;");
}
on(release)
{
var val = _parent.myDB.runQuery("UPD
}
ASKER
Thanks but the issue is that it inserts the string "+thisfield.text+" instead of the value inside that textfield which is a number or anything else the end user enters. Not sure how to handle that on an update query.
Try this.
_parent.myDB.runQuery("UPD ATE preferences SET typenum = '"+thisfield.text+"' WHERE id = 1;");
_parent.myDB.runQuery("UPD
or also try this.
_parent.myDB.runQuery("UPD ATE preferences SET typenum = "+chr(34)+thisfield.text+c hr(34)+" WHERE id = 1;");
_parent.myDB.runQuery("UPD
ASKER
Ok, let me try those..
If the above dosen't work also try this and post here the trace.
var sql = "UPDATE preferences SET typenum = '"+thisfield.text+"' WHERE id = 1;";
trace (sql)
_parent.myDB.runQuery(sql) ;
var sql = "UPDATE preferences SET typenum = '"+thisfield.text+"' WHERE id = 1;";
trace (sql)
_parent.myDB.runQuery(sql)
ASKER
Ok, I tried the first solution:
_parent.myDB.runQuery("UPD ATE preferences SET typenum = '"+thisfield.text+"' WHERE id = 1;");
and it inserted undefined
_parent.myDB.runQuery("UPD
and it inserted undefined
ASKER
Ok, I also tried:
_parent.myDB.runQuery("UPD ATE preferences SET typenum = "+chr(34)+thisfield.text+c hr(34)+" WHERE id = 1;");
and that didn't update anything.
_parent.myDB.runQuery("UPD
and that didn't update anything.
ASKER
The trace on the above is:
UPDATE preferences SET typenum = 'undefined' WHERE id = 1;
UPDATE preferences SET typenum = 'undefined' WHERE id = 1;
ok so that is correct.
This is the right one:
_parent.myDB.runQuery("UPD ATE preferences SET typenum = '"+thisfield.text+"' WHERE id = 1;");
but now your problem is the textfield because it's unefined or empty. Where is the textfield located?
This is the right one:
_parent.myDB.runQuery("UPD
but now your problem is the textfield because it's unefined or empty. Where is the textfield located?
ASKER
The textfield is located on the _root with the button to update. Both are flash components.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
YES!!!!!!
_root didn't get referneced.
Thanks ch2!
_root didn't get referneced.
Thanks ch2!
nice it worked for you!
Thanks for the points.
Thanks for the points.
I searched a bit and got to this link: http://www.thecodezone.com/downloads/sqlite.html
So try like this
// Connect
var id:Boolean = _parent.myDB.connect("my.d
// Check connection
if (id) {
trace("connected");
var stat:Boolean = _parent.myDB.runQuery("UPD
if (stat) {
// Check if inserted
trace("Record inserted");
} else {
trace("Record not inserted");
}
} else {
trace("Record not connected");
}
_parent.myDB.close;