Solved

Querying Access Database from Flash

Posted on 2004-03-28
5
141 Views
Last Modified: 2010-04-03
Hi,

I am trying to set up a simple page that uses Flash and ASP to display information from the Microsoft Access database. I would appreciate if somebody can give me instructions (samples) how to create a Flash file, Database and ASP page to do it.

Thanks a lot.
0
Comment
Question by:kirylm
  • 2
5 Comments
 
LVL 22

Accepted Solution

by:
rascalpants earned 250 total points
ID: 10704976
your data output on the ASP page needs to be displayed in the following format:

variable1=value1&variable2=value2&variable3=value3&

or like this:

name=Bob&phone=555-5555&email=bob@aol.com&


you do this by using similar ASP code like the below:

<%
dim MyConn, SQL_query, rs
dim name, phone, email
 
Set MyConn = Server.CreateObject("ADODB.Connection")
MyConn.open "Provider=SQLOLEDB;Data Source=DATABASENAME;Initial Catalog=CATALOGNAME;uid=USERNAME;pwd=PASSWORD"
SQL_query = "SELECT * FROM tableName"
Set rs = server.createobject("ADODB.Recordset")
rs.open SQL_query,MyConn,1,2


screen_no = 1
WHILE NOT rs.EOF

response.write "name="& rs("name") &"&phone="& rs("phone") &"&email="& rs("email") &"&"

rs.MoveNext
WEND
%>


then in the first frame of your movie, you put this LoadVars code there:


myData = new LoadVars();
myData.onLoad = function(success){
  if(success){
    _root.name = myData.name;
    _root.phone = myData.phone;
    _root.email = myData.email;
  } else {
    trace("error");
  }
};

myData.sendAndLoad("variablesPage.asp", myData, "POST");


then you just use the variables that are in the root of the movie and display then when you want.....


if you need more help, let me know...

rp
0
 

Expert Comment

by:scotman23
ID: 10715900
you can do it without the loadvars method. On the ASP page where you will have the flash file.... in the source code just enter the values where it calls in the flash file. e.g.

source="myfile.swf?<%=Response.Write "name="& rs("name") &"&phone="& rs("phone") &"&email="& rs("email") &"&">"

this will pass the variables directly in to _level0 of your movie for you to use
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 10724229
the LoadVars() method is preferred because of a few different reasons...

- you page and movie will load faster because the data is not called until needed

- and because you can control when the data is loaded, you can move the code to other parts of the movie or place use it with a button to load the data.

- you have much better control over your data by loading it into an Object

- you can also create a preloader based on the properties of that Object which are more accurate

- your variables from your database are not displayed in the source code of the html(slight security risk)


...bandwidth is still a problem for a lot of users, and unless you are only passing a very small amount of data to the movie, then you should wait to load it when it is needed.  The same theory applies to sections of a movie as well, and should be loaded at runtime if possible.

since we don't have much to go on from the question details, you should assume that the amount of data being passed is enough to slow down the loading of the movie, and that some of the data could be private in nature...

I use your(scotman23) method quite a bit when I am only passing 2 or 3 variables, but when I want to pass more data, I want to have it load only when I need it...

rp
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

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…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

760 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

23 Experts available now in Live!

Get 1:1 Help Now