-
Proper syntax for rundbquery in Flash Studio?
Hello,
I am trying to update a field in an access database using Flash Studio pro. I want the user to be able to change the value of the field that is already displayed in a text field. Then click a button to update the database. I can connect to the db and display the info I want, but have not been able to update the database. Here is what I have so far in my 2 frame movie.
// This is on frame 1. Connects to my database and selects all the data.
fscommand("flashstudio.connecttodb", "\"jeff_db.mdb\"");
stop();
fscommand("flashstudio.dbsuccess", "return");
play();
fscommand("flashstudio.selectfromdb", "\"SELECT * FROM people\"");
// All of the following code is on frame 2. I have a text field with the variable name doc_fn that displays a name using the getfieldfromdb command.
stop();
fscommand("flashstudio.getfieldfromdb","\"FirstNam e\",\"1\",doc_fn");
// THIS IS WHERE THE PROBLEM IS. WHEN I RUN THE rundbquery I GET A SYNTAX ERROR BASED ON doc_fn_sql. AM I REFERENCING THE VARIABLE doc_fn INCORRECTLY? IS THERE SOMETHING WRONG WITH THE CONCATENATION?
doc_fn_sql = "UPDATE people SET FirstName =" + doc_fn + "WHERE ID = 1";
// Clicking the button runs the rundbquery and selectfromdb commands.
red_btn.onRelease = function() {
fscommand("flashstudio.rundbquery","doc_fn_sql");
fscommand("flashstudio.selectfromdb", "\"SELECT * FROM people\"");
gotoAndPlay(2);
}
-
Banned By GMF Wannabe
Hey, send your FLA and MDB file to support@multidmedia.com and I'll take a look for you.
-
Banned By GMF Wannabe
Hey, I just noticed your SQL is missing two single quotes and you also need to construct it when the button is pressed, not before!
The code should be:
Code:
red_btn.onRelease = function() {
doc_fn_sql = "UPDATE people SET FirstName = '"+doc_fn+"' WHERE ID = 1";
fscommand("flashstudio.rundbquery", "doc_fn_sql");
fscommand("flashstudio.selectfromdb", "\"SELECT * FROM people\"");
gotoAndPlay(3);
};
I've fixed your FLA and sent it back to you too!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|