Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

getting data from a .asp page

Explorer ,
Nov 18, 2013 Nov 18, 2013

I seem to have some issue getting infro from a database via .asp into flash, im am extremely new at this so any help would be appreciated.

flash code:

var loader : URLLoader = new URLLoader;

    var urlreq:URLRequest = new URLRequest("index.asp");

    var urlvars: URLVariables = new URLVariables;

     var theText:TextField = new TextField();

    loader.dataFormat = URLLoaderDataFormat.VARIABLES;

    urlreq.method = URLRequestMethod.POST;

    loader.load(urlreq);

     theText.text = urlvars.firstName + " name."

     addChild(theText);

ASP Code(connected to DB ok and can pull info into html page):

<%

Dim firstName, lastName

firstName = rs1.Fields.Item("firstName").Value

lastName = rs1.Fields.Item("lastName").Value

%>

this flash file is then embedded into the .asp page. Any help would be apprecated, thanks!

TOPICS
ActionScript
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2013 Nov 18, 2013

what are you trying to do?  get data from your asp file or send data to it?

that code you showed won't do either.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 18, 2013 Nov 18, 2013

I would wish to do both, if you have the time to explain or a site to show. If not I just would like to know how to retrieve the data from the asp page. I have tried to look on multiple sites but they weren't very helpful. Thank you for your help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2013 Nov 18, 2013

to send data:

var loader : URLLoader = new URLLoader;

    var urlreq:URLRequest = new URLRequest("index.asp");

    var urlvars: URLVariables = new URLVariables;

    urlvars.firstname = sometextfield.text;

urlvars.lastname = someothertextfield.text;

urlreq.data=urlvars

    loader.dataFormat = URLLoaderDataFormat.VARIABLES;

    urlreq.method = URLRequestMethod.POST;

    loader.load(urlreq);

to receive data:

var loader : URLLoader = new URLLoader;

loader.addEventListener(Event.COMPLETE,completeF);

    var urlreq:URLRequest = new URLRequest("index.asp");

    var urlvars: URLVariables = new URLVariables;

    urlvars.firstname = sometextfield.text;

urlvars.lastname = someothertextfield.text;

urlreq.data=urlvars

    loader.dataFormat = URLLoaderDataFormat.VARIABLES;

    urlreq.method = URLRequestMethod.POST;

    loader.load(urlreq);

function competeF(e:Event):void{

trace(loader.data);

}

///

and your asp file should use something like the following to return data:

Response.Write(firstName);

Response.Write(lastName);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 20, 2013 Nov 20, 2013

Thank you kglad, very helpful, however I think I may have an issue with my asp page, I tried the response.write my variable, and then tried to trace it out into my flash, however Im not getting any info back. When I trace loader.data I get a very long string of information. Here is how I have my asp set up.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

<!--#include file="Connections/DustinsDB.asp" -->

<%

Dim rs1__MMColParam

rs1__MMColParam = "1"

If (Request.QueryString("ID") <> "") Then

  rs1__MMColParam = Request.QueryString("ID")

End If

%>

<%

Dim rs1

Dim rs1_cmd

Dim rs1_numRows

Set rs1_cmd = Server.CreateObject ("ADODB.Command")

rs1_cmd.ActiveConnection = MM_DustinsDB_STRING

rs1_cmd.CommandText = "SELECT * FROM NAMES WHERE ID = ? ORDER BY firstName ASC"

rs1_cmd.Prepared = true

rs1_cmd.Parameters.Append rs1_cmd.CreateParameter("param1", 5, 1, -1, rs1__MMColParam) ' adDouble

Set rs1 = rs1_cmd.Execute

rs1_numRows = 0

%>

<%

Dim firstName, lastName

firstName = rs1.Fields.Item("firstName").Value

lastName = rs1.Fields.Item("lastName").Value

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Flash DB Test</title>

</head>

<body>

<%Response.Write(firstName)%>

</body>

</html>

<%

rs1.Close()

Set rs1 = Nothing

%>

Again, I apprecate all your help. Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 20, 2013 Nov 20, 2013

that looks like a page that's supposed to be displayed in a browser, not one used to send and receive data from flash.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 21, 2013 Nov 21, 2013

Do you happen to know where I can find a resource where I can see how the asp page is supposed to look I removed the HTML data from the page and just left the asp database connection and variables with response.write outputting those variables but I still seem to have trouble. Thank you for your help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 21, 2013 Nov 21, 2013
LATEST
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines