Solved

update query to SQLite database

Posted on 2006-11-27
14
234 Views
Last Modified: 2012-08-14
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("UPDATE preferences SET typenum = \""+thisfield.text+"\" WHERE id = 1;");

}
0
Comment
Question by:COwebmaster
  • 7
  • 7
14 Comments
 
LVL 11

Expert Comment

by:ch2
ID: 18026738
Well did never use that class but as i know a bit of sqlite and mysql. Did you open a connection to the database?

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.db");
// Check connection
if (id) {
      trace("connected");
      var stat:Boolean = _parent.myDB.runQuery("UPDATE preferences SET typenum = \""+thisfield.text+"\" WHERE id = 1;");
      if (stat) {
            // Check if inserted
            trace("Record inserted");
      } else {
            trace("Record not inserted");
      }
} else {
      trace("Record not connected");
}
_parent.myDB.close;
0
 

Author Comment

by:COwebmaster
ID: 18028543
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.
0
 
LVL 11

Expert Comment

by:ch2
ID: 18028698
Try this.

_parent.myDB.runQuery("UPDATE preferences SET typenum = '"+thisfield.text+"' WHERE id = 1;");
0
 
LVL 11

Expert Comment

by:ch2
ID: 18028720
or also try this.

_parent.myDB.runQuery("UPDATE preferences SET typenum = "+chr(34)+thisfield.text+chr(34)+" WHERE id = 1;");
0
 

Author Comment

by:COwebmaster
ID: 18029068
Ok, let me try those..
0
 
LVL 11

Expert Comment

by:ch2
ID: 18029189
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);
0
 

Author Comment

by:COwebmaster
ID: 18029907
Ok, I tried the first solution:

_parent.myDB.runQuery("UPDATE preferences SET typenum = '"+thisfield.text+"' WHERE id = 1;");

and it inserted undefined
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:COwebmaster
ID: 18029929
Ok, I also tried:

_parent.myDB.runQuery("UPDATE preferences SET typenum = "+chr(34)+thisfield.text+chr(34)+" WHERE id = 1;");

and that didn't update anything.
0
 

Author Comment

by:COwebmaster
ID: 18029943
The trace on the above is:

UPDATE preferences SET typenum = 'undefined' WHERE id = 1;
0
 
LVL 11

Expert Comment

by:ch2
ID: 18029974
ok so that is correct.

This is the right one:

_parent.myDB.runQuery("UPDATE 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?
0
 

Author Comment

by:COwebmaster
ID: 18030003
The textfield is located on the _root with the button to update.  Both are flash components.
0
 
LVL 11

Accepted Solution

by:
ch2 earned 500 total points
ID: 18030010
so try like this.

_parent.myDB.runQuery("UPDATE preferences SET typenum = '"+_root.thisfield.text+"' WHERE id = 1;");
0
 

Author Comment

by:COwebmaster
ID: 18030053
YES!!!!!!

_root didn't get referneced.  

Thanks ch2!
0
 
LVL 11

Expert Comment

by:ch2
ID: 18030619
nice it worked for you!

Thanks for the points.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sothink decompiled SWF to Flex: how to build in Adobe Flash Premium Builder? 3 764
Microsoft WSUS 4 90
Removing Flash from Website 6 45
Adobe Products Forum? 3 147
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now