PDA

View Full Version : Insert data into database from Flash



nupur2609
March 16th, 2009, 02:27 AM
Hi
I am completely new to Flash and actionscript.I have a small project which requires me to submit details into a MS Access Database. I have created an asp scrip to do the same but it doesnt seem to be working. I am posting the code.Please Help !!

my fla code
********
import flash.events.Event;
import flash.net.*;
Enter_btn.addEventListener(MouseEvent.CLICK,Submit );
function Submit(event:MouseEvent):void{
var myRequest:URLRequest = new URLRequest("DB11.asp");
var myLoader:URLLoader = new URLLoader();
var myVariables:URLVariables = new URLVariables();

myVariables.tVF = "5";
myVariables.tVB = "6";
myVariables.tAF = "7";
myVariables.tVB = "8";
myVariables.tTotal = "9";

trace(myVariables.tVF);


myRequest.method = URLRequestMethod.POST;
myRequest.data = myVariables;
myLoader.addEventListener(Event.COMPLETE, onLoaded);
myLoader.load(myRequest);
function onLoaded(evt:Event):void {
trace("here we get the data back:" +myLoader.data);
}
}


my asp Code
******************

<%@language = "VBScript" %>
<%

strVF = Request("tVF")
strVB = Request("tVB")
strAF = Request("tAF")
strAB = Request("tAB")
strTotal = Request("tTotal")

strDB = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("BaselineTest.mdb") & ";DefaultDir=" & Server.MapPath(".") & ";DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5"

MyPath=Server.MapPath("BaselineTest.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open strDB

SQLInstr = "INSERT INTO Score (AF, AB, VF,VB,Final) VALUES ('" & strAF & "','" & strAB & "','" & strVF & "','" & strVB & "','" & strTotal & "')"
conn.Execute SQLInstr
Response.Write("OK")
Conn.close
%>

I am running it Using IIS 7.0 and all the files are in my wwwroot folder.
What am I doing wrong here??

Thanks

numediaweb
March 16th, 2009, 04:51 AM
what's the error you get? did you check in what part do you have probleme: try to check if flash sends data to your asp file (using echo or something), if it does, then check your asp/database.

nupur2609
March 16th, 2009, 05:24 AM
what's the error you get? did you check in what part do you have probleme: try to check if flash sends data to your asp file (using echo or something), if it does, then check your asp/database.


Hi
I have changed the code a bit and posted the new one above.I am not getting any error at all now..It just won't write into the database.
I am trying to check if data is received by asp,but since am new to this whole thing,cant figure out how exactly do I check that.

Thanks