Saturday, May 17, 2008

Susten 100 Progesterone Soft Gelatin Capsules

Read records from a mysql database and asp as3

We read the records in a mysql db through asp script that we pass an order cadeena the sql, and returns a xml with the result.
In this example I added a datagrid to the stage, I called dg and is responsible for receiving calls datos.Se such as: var
dba: leeDb leeDb = new ();
datosdb.carga_datos ("select * from users" )
Files: leeDb.as, leeDb.asp

leeDb.as
  

package code {import flash.display .*;
import flash.events .*;
import flash.net .*;
import fl.controls.DataGrid;
fl.controls.dataGridClasses.DataGridColumn import, import
fl.data.DataProvider;
/ / Class public class
leeDb
extends Sprite {public var dg: DataGrid;
/ / constructor public function
leeDb (): void {
trace ("constructor");}

carga_datos public function (sql: String):
void {/ / var sql to URLVariables
URLVariables: URLVariables = new URLVariables;
urlVariables.sql = sql;

/ / define values \u200b\u200bURLRequest var
call: URLRequest = new URLRequest;
URLRequest.method = URLRequestMethod.POST;
URLRequest.url = "http://localhost/webprueba/codigo/leeDb.asp"
URLRequest.data = URLVariables;

/ / I loader and event
was urlLoader: URLLoader = new URLLoader;
urlLoader.addEventListener (Event.COMPLETE, cargaCompleta);

/ / leemos
urlLoader.load (urlRequest);


} / / private function _______________funciones___________________________________
cargaCompleta (Eventos: Event) : void {
was myxml: XML = new XML (evento.target.data);
, the overall direction of Faith: int = myxml.child ("*"). length ();
was totalCampos: int = myxml.child (0) . child ("*"). length ();
was dp: data provider = new data provider (myxml);
/ / ponemos columns
was spine: DataGridColumn = new DataGridColumn ();
for each (var item: XML in myxml.child (0). Elements ()) {column = dg.addColumn
(new DataGridColumn (item.name (). ToString ()));
columna.width = 300 / totalCampos;}

dg.move (0.200);
dg.width = 300;
dg.rowCount = totalRegistros;
dg.dataProvider = dp;

}}}




leeDb.asp
  
\u0026lt;% 'declare variables dim
dbConexion, sql, rs, x, y,
table' db connection string
dbConexion = "Driver = {mySQL ODBC 3.51 Driver}; Server = localhost, Port =; Option = 4; Database = test; Uid =; Pwd =; "
'variable charge
sql sql = Request.Form ("sql")
' read data
table Set rs = Server.CreateObject ("ADODB.Recordset") rs.Open sql
, dbConexion
table = rs.GetRows
'
xml file header Response.ContentType = "text / xml" Response.Write
"\u0026lt;? xml version = '1 .0' encoding = 'UTF-8'?>"
Response.Write "\u0026lt;regs>"
for x = 0 to UBound (table 2)
Response.Write "\u0026lt;reg>"
for y = 0 to UBound (table 1)
Response.Write "<" & rs.Fields(y).Name & ">" Response.Write
board (y, x )
Response.Write "\u0026lt;/" & Rs.Fields (y). Name & ">"

next Response.Write ("\u0026lt;/ reg>")

next Response.Write ("\u0026lt;/ regs>") rs.Close

Set rs = Nothing
%>

0 comments:

Post a Comment