Actionscript 3.0 and Microsoft Access or Databases
Hello All,
I have a question that I have needed help with for a while now and still cannot figure out. I have a local Microsoft Access Database and I would like to connect it to my flash project to dynamically load information. My company I work for does not use any kind of software except for .NET. I am at a loss because everything I find can't be used with Microsoft Access. Any help would be very appreciated. Thanks.
I don't think using flash stand-alone will accomplish what you want, but you can use SWF Studio to create an exe that will allow you to interact with an Access db almost however you want.
I've always been very pleased with their functionality and support.
Hope that helps!
Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.
Amazing thanks so much! My boss actually asked me if flash was the only way to go about projects so hopefully the SWF Studio will be a better fit. Thanks again!
SWF Studio actually creates an exe using a flash built swf file, but it provides a TON of features that are not available natively in flash, such as system calls, db connections, etc.
Take a look at their site, you can download the trial version which is fully functional, but the exe files that it creates only work for a few days.
northcode.com
Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.
Ok....So I have downloaded the SWF Studio as instructed and I got everything to program to run smoothly, but for some reason I cannot get the code to work right. I have been trying to link a simple Access Database to a basic flash document to just read one field of information and set it to a text field to view. I am just trying to see if I can get it to work. Now, here is my code so far.....
open_btn.addEventListener(MouseEvent.CLICK,openStu ff);
function openStuff():void
{
ssCore.ADO.setConnectString({connectString:"Provid er=Microsoft.Jet.OLEDB.4.0; Persist Security Info=False; Data Source="+ssGlobals.ssStartDir+"\\Example.mdb;"});
ssCore.ADO.open();
ssCore.ADO.setWhere({clause:"Rank = 1"});
ssCore.ADO.setTable({name:"2004 Billionaires"});
var return_obj = ssCore.ADO.execSQL({sql:"SELECT Name"});
textField1.text = return_obj.result.toString();
ssCore.ADO.close();
}
Can anyone help me figure out why when I run this it doesn't do anything? It builds fine and runs ok, but when I click the button nothing happens. Thanks in advance.
northcode? you around to help with this?? I haven't done anything with Access db and SWF Studio myself...
nate, if he doesn't reply to this post, you can probably shoot him a PM. He's generally VERY good about helping out with all SWF Studio related stuff and has answered SOO many of my questions and helped me out with stuff from super basic stupid things I was doing wrong to some fairly complex solutions...
He might be on break for New Years, but I don't think they give him any vacation over there...
Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.
#1 - You're calling ADO.open before you've told the ADO plugin what table you want to open and what data you want from it.
#2 - You can use setWhere/setTable/etc OR execSQL but they can't be used together. execSQL gives you direct control over the SQL query, the other methods allow you to define your query without using SQL.
#3 I dont' see where you enabled synchronous commands (ssDefaults.synchronousCommands = true). When we released SWF Studio 3.0 everything was async. When we added support for sync calls we didn't wan to break existing code so we added ssDefaults to let you change the default call mode.
Here's a little example that shows how to pull data from an Access database. The output is sent to the SWF Studio Trace Tab but you can do whatever you want with it once you have it in Flash. It's in AS2 but it will be very easy to pull the calls you need into your AS3 project.
Thanks very much for the reply. The code you sent worked at first but once I tried the code in my project as seen below, both stopped getting data from the Database. Here is my code thus far...
openbtn.addEventListener(MouseEvent.CLICK,openStuf f);
function openStuff(e:MouseEvent):void
{
ssCore.init();
ssDefaults.synchronousCommands = true;
ssCore.ADO.setConnectString({connectString:"Provid er=Microsoft.Jet.OLEDB.4.0; Persist Security Info=False; Data Source="+ssGlobals.ssStartDir+"\\Example.mdb;"});
ssCore.ADO.setSQL({sql:"select * from [2004 Billionaires] where Rank = '1'"});
var return_obj = ssCore.ADO.open();
if (return_obj.success)
{
return_obj = ssCore.ADO.getRows();
It should work where you have it now, but the calls to ssCore.init and to set ssDefaults flag should really only be done once at the beginning of your application.
I'm guessing that the space in "Provid er=Microsoft.Jet.OLEDB.4.0;" is something that the forums are doing, but just in case.. it should not be there, it should be "Provider=...".
If you want to send your FLA and SPF to [email protected] I'll have a look at it for you (assuming you're using the same MDB file I sent you for testing).
I figured it out! I didnt have the .SWC classes installed correctly in flash. It works great now. Thanks so much for all your help Northcode and Flashpipe.