need help

19 views
Skip to first unread message

Turker Bilge

unread,
Jul 3, 2014, 6:21:52 PM7/3/14
to as...@googlegroups.com
im using Flsh Cs6. and i achieved to connect to my external database but i have realy simple problem like this.
how i can send datas to my Array(aRoster).
Thanks ...



function action()
{

bldRosterGrid(aDg);
var st:Statement = con.createStatement();
        
var aRoster:Array = st.executeQuery("SELECT * FROM Mevzular");


aDg.dataProvider = new DataProvider(aRoster);
aDg.rowCount = aDg.length;
aDg.setSize(600, 300);

}

vasuki

unread,
Jul 4, 2014, 3:26:53 AM7/4/14
to as...@googlegroups.com
hi,

you can try something like this  ( not flash cs6 but Flex .. still code signature is pretty much same)
private function OpenSomeRecord():void
{
CursorManager.setBusyCursor();
var st:Statement =  conn.createStatement();
st.sql = "select * from foo where fooNo = ? ";
st.setString(1,_currNo);
var _srToken:MySqlToken = st.executeQuery();
_srToken.info = 'getFoo';
_srToken.addResponder(new AsyncResponder(result, fault, _srToken));
}
private function result(data:Object, token:Object):void {
CursorManager.removeBusyCursor();
var rs:ResultSet;
if ( token.info == "getFoo" ) {
rs = ResultSet(data);
var recSize:int = rs.size();
var _recArr:ArrayCollection = new ArrayCollection();
if ( recSize >0){
_recArr = rs.getRows(true,0,rs.size());
}
_recArr.refresh();
yourDG.DataProvider = _recArr;
}
}
private function fault(info:Object, token:Object):void {
Alert.show(token.info + " Error: " + info);
CursorManager.removeBusyCursor();                              
}

in case if you prefer events instead of responder, 
replace responders, with...
_srToken.addEventListener(MySqlEvent.RESULT,yourResulthandlerfunction);
_srToken.addEventListener(MySqlErrorEvent.SQL_ERROR ,your fault error hander function);

private function yourResulthandlerfunction(e:MySqlEvent):void
{
//remove busy curosr or enable componenet;
var _recArr:ArrayCollection = new ArrayCollection();
if (e.ResultSet.Size() > 0)
{
_recArr = e.resultSet.getRows(true,0,e.resultSet.size());
//refresh array collection
//bind it with DG

}
}
// fault handler.

Best Regards
Vasuki



From: Turker Bilge <turke...@gmail.com>
To: as...@googlegroups.com
Sent: Friday, July 4, 2014 5:21 AM
Subject: need help

--
You received this message because you are subscribed to the Google Groups "asSQL" group.
To unsubscribe from this group and stop receiving emails from it, send an email to assql+un...@googlegroups.com.
To post to this group, send email to as...@googlegroups.com.
Visit this group at http://groups.google.com/group/assql.
For more options, visit https://groups.google.com/d/optout.


enver sejdija

unread,
Jul 4, 2014, 8:49:11 AM7/4/14
to assql
You can not do it in this way, you must do something le this:

function action()
{

bldRosterGrid(aDg);

            var st:Statement = con.createStatement();
            var _sql:String="SELECT * FROM Mevzular";
             var _query:MySqlToken = st.executeQuery(_sql);
                if(!_query.hasResponder())
                        _query.addResponder(new AsyncResponder(handleComplete,HandleError,sql));

}

            private function handleComplete(data:Object, token:Object):void
            {
               var rs:ResultSet = ResultSet(data);
               aRoster=rs.getRows();   
aDg.dataProvider = new DataProvider(aRoster);
         aDg.rowCount = aDg.length;
                aDg.setSize(600, 300);
           }
            private function HandleError(data:Object, token:Object):void
            {
              Alert.Show(String(token));
           }

Regards
Enver



César Mendoza

unread,
Jul 4, 2014, 9:13:27 AM7/4/14
to as...@googlegroups.com


--
You received this message because you are subscribed to the Google Groups "asSQL" group.
To unsubscribe from this group and stop receiving emails from it, send an email to assql+un...@googlegroups.com.
To post to this group, send email to as...@googlegroups.com.
Visit this group at http://groups.google.com/group/assql.
For more options, visit https://groups.google.com/d/optout.



--
Saludos.
César Javier Mendoza.

enver sejdija

unread,
Jul 4, 2014, 9:15:24 AM7/4/14
to assql
Gracias Amigo
what clever you doing today?

César Mendoza

unread,
Jul 4, 2014, 10:57:50 AM7/4/14
to as...@googlegroups.com
what?


On Fri, Jul 4, 2014 at 10:15 AM, enver sejdija <nuhij...@hotmail.com> wrote:
Gracias Amigo
what clever you doing today?

--
You received this message because you are subscribed to the Google Groups "asSQL" group.
To unsubscribe from this group and stop receiving emails from it, send an email to assql+un...@googlegroups.com.
To post to this group, send email to as...@googlegroups.com.
Visit this group at http://groups.google.com/group/assql.
For more options, visit https://groups.google.com/d/optout.

Turker Bilge

unread,
Jul 9, 2014, 4:57:12 PM7/9/14
to as...@googlegroups.com
thanks somuch for your replies but i dont have flex so i dont have AsyncResponder class ... could you offer me  a way for cs6 or flash builder ..

enver sejdija

unread,
Jul 10, 2014, 3:51:51 AM7/10/14
to assql
Problem yok arkadash,
 i am using flash builder 4.6 ,just include this line:
import mx.rpc.AsyncResponder;


Date: Wed, 9 Jul 2014 13:57:12 -0700
From: turke...@gmail.com
To: as...@googlegroups.com
Subject: Re: need help


thanks somuch for your replies but i dont have flex so i dont have AsyncResponder class ... could you offer me  a way for cs6 or flash builder ..

Reply all
Reply to author
Forward
0 new messages