How to send data from Flash to Access Database with ASP
by Carlos Pinho, January 29th, 2007

Usually people want’s to send data from flash to a database. But as we need to use a script, with asp, .net, php or other, turns hard to complete our job. So here you will find simple code to help you. Hope you enjoy.

On the flash movie use the normal code to send variables to outside the movie.

The flash main code should be something like this:

function senddata()
{
var sendVars = new LoadVars();
sendVars.name = name.text;
sendVars.surname = surname.text;
sendVars.email = email.text;
sendVars.login = login.text;
sendVars.password = password.text;
sendVars.info = info.selected;
sendVars.load(”sendcadastro.asp?” + sendVars.toString());
sendVars.onLoad = function ()
{
if (sendVars.ok == “true”)
{
nextFrame ();
}
else
{
senha2msg.text = “Login já existe!”;
} // end else if
};
} // End of the function
stop ();
bt_send.onRelease = function ()
{
senddata();
};

On the asp file, use the following code:

<%@LANGUAGE=”VBSCRIPT” CODEPAGE=”1252″%>
<%
‘Open the database ———————————————
set bd=server.createobject(”adodb.connection”)
cnpath=”DBQ=” & server.mappath(”../db/mydb.mdb”)
bd.open “DRIVER={Microsoft Access Driver (*.mdb)}; ” & cnpath
‘Variaveis recebidas do Flash ————————————
name  = trim(request(”name”))
surname  = trim(request(”surname”))
email  = trim(request(”email”))
login  = trim(request(”login”))
password = trim(request(”password”))
info  = trim(request(”info”))
‘Verify if login exists already ——————————–
sql= “SELECT * FROM LOGIN WHERE login = ‘”& login &”‘ “
Set busca = bd.Execute(sql)
if busca.eof then

‘Sending data to the LOGIN table on database ————————–
Set RS = Server.CreateObject(”ADODB.Recordset”)
RS.Open “LOGIN”,bd,1,3
RS.AddNew
RS(”name”)   = name
RS(”surname”) = surname
RS(”email”)   = email
RS(”login”)   = login
RS(”password”)= password
RS(”info”)  = info
RS.Update
response.write “ok=true”
else
response.write “ok=false”
end if
‘Fecha ——————————————————–
set busca = nothing
set RS = nothing
bd.close
%>

You must build a database, on this example mydb.mdb, with a table with the same variable names.

i’ve inserted the source file at the place where i will develop my website. You can find the source files at http://free.ipdz.com/cpinho/cadastro.html , you can also test before make the download if you want.

i’ts in portuguese but you just need to change the field names on each file. Hope you enjoy. Pls give me your comments. It’s very important to me, to know what you think, as also, what kind of examples you are interested.


Tags: , , , ,

ShareThis

7 Responses to “How to send data from Flash to Access Database with ASP”

  1. Darren Says:

    Look great in theory but I am having problems getting it to work.

    Could you please share the source files? I tried the above link but it appears dead.

    Many thanks for sharing.

    Darren

  2. minesh Says:

    I tried you code in my work . but it doesnt work.
    But plesae let me know that
    what other ways are there to save the information to database from flash components.
    such as textField, comboBox, textArea,radioBtn
    etc..

  3. Vipin Says:

    i try it but data not send in database.

  4. Vipin Says:

    this is very help ful me but it is not work in my site.
    thanks

    pls give me solution

  5. cpinho Says:

    Hi,

    Usually the problem is because of two things, 1st if using windows iis, it give us some problems. Check if everyting is well configured. I prefer to work with a remote server i/o localhost. 2nd, if you are at a remote server, than check the db connection string, as some hosting companies have their own configuration, all the other will not work.

  6. Justin Says:

    Can you fix the link to the source files pretty please? This would be very helpful!!

  7. Zell Says:

    I think this code will save my life i’ve been working on this type of project and this is the last piece i need thanks

    I hope i can make it work asap because my project deadline was 5hrs away from now

    thank you for saving my life LOL!!!!!!!!!

    wakekekekekekekekekekekekekekeke

    God bless to everyone

Let leave a Comments for this post.

Close