Home > database >  Help: how asSQL2.8 connection mysql query record and display
Help: how asSQL2.8 connection mysql query record and display

Time:10-06

Himself with as3 AS3.0 development projects, use the background such as PHP, it cited asSQL2.8. SWC library files directly manipulate mysql, program can insert and modify the record, but I don't know how to display query log, for a long time didn't get up, can only be executed to
 var token: MySqlToken=st. executeQuery (SQL); 
here, behind the function estimation in the wrong, which help change, will be appreciated! The code is as follows:
 
Package
{
/* *
* @ author: pengzhe
* @ date: 2017-8-21 afternoon 5:59:53
* @ version: airee334 V1.0.0
* @ description: & lt; & lt; Please briefly describe the main functions of the airee334 here & gt;>
*/
The import com. Maclema. Mysql. The Connection;
The import com. Maclema. Mysql. MySqlToken;
The import com. Maclema. Mysql. The ResultSet;
The import com. Maclema. Mysql. The Statement;
The import com. Maclema. Mysql. Events. MySqlErrorEvent;
The import com. Maclema. Mysql. Events. MySqlEvent;

The import flash. Display. Sprite;



Public class airee334 extends Sprite
{
//attributes -
//initialization -
The public function airee334 ()
{
Var host: String="localhost";
Var port: int=3306;
Var user: String="root";
Var PWD: String="123456";
Var database: String="assq";
Var con: Connection=new Connection (host, port, user, PWD, database).
Con. The connect ();
Var st: Statement=con createStatement ();
Var SQL: String="SELECT id, name FROM the user".
Var token: MySqlToken=st. executeQuery (SQL);
Token. AddEventListener (MySqlEvent. The RESULT, the function (e: MySqlEvent) : void {
Var rs: the ResultSet="e.r esultSet;
Var userName: String=rs. Get String (" id ");
Var roleId: String=rs. Get String (" name ");

While (rs), next ())
{

Var _userNameArr: Array=new Array ();
Var _roleIdArr: Array=new Array ();
_userNameArr. Push (userName);
_roleIdArr. Push (roleId);

}
Trace (_userNameArr);
Trace (_roleIdArr);
Con. Disconnect ();
});

Token. AddEventListener (MySqlErrorEvent SQL_ERROR, function (e: MySqlErrorEvent) {
Trace (" access error... ");
Con. Disconnect ();

});


}
//interface -- -- -- -- --
//event -- -- -- -- --
}
}

CodePudding user response:

Not tested, there was an obvious wrong place seems changed under
 
Token. AddEventListener (MySqlEvent. The RESULT, the function (e: MySqlEvent) : void {
Var rs: the ResultSet="e.r esultSet;
Var _userNameArr: Array=new Array ();
Var _roleIdArr: Array=new Array ();

While (rs), next ())
{

Var userName: String=rs. Get String (" name ");
Var roleId: String=rs. Get String (" id ");
_userNameArr. Push (userName);
_roleIdArr. Push (roleId);

}
Trace (_userNameArr);
Trace (_roleIdArr);
Con. Disconnect ();
});

CodePudding user response:

Is this code are not performed, don't know where is wrong,
  • Related