Hmm AFAIK, you cannot return a custom class from .Net back to Flex
like that (yet)..I could be wrong here so if somebody knows
otherwise...please do tell :-)
 
Try this instead :

//=========

public

ASObject getEmployee(string au_id) 
{

conn =

new SqlConnection("data source=dt1305-priyanka\\netsdk;
database=pubs;uid=sa;pwd=welcome;");
conn.Open();

SqlCommand sqlcomm = 

new SqlCommand(); 

sqlcomm.Connection=conn;

sqlcomm.CommandType = CommandType.Text;

sqlcomm.CommandText = "SELECT * FROM titleauthor WHERE au_id ='" + au_id + "'";

SqlDataReader readerObj = sqlcomm.ExecuteReader();

ASObject title = 
title.ASType = "RemoteTest.Title"
new ASObject(); 

while (readerObj.Read()) 
{

title.AddKey("au_id",au_id);

title.AddKey("title_id" , readerObj.GetString(1));

title.AddKey("au_ord",  (System.Byte)readerObj.GetValue(2));

title.AddKey("royaltyper", (Int32)readerObj.GetValue(3));

}


return title; 
}

HTH
- superabe



On 8/3/05, priya s <[EMAIL PROTECTED]> wrote:
> Hi all,
>  I m trying to return a custom object from .NET to Flex. It s returning
> Nothing. But I m able to send the same custom object from Flex to .NET.
>  
> 1) The addTitle method, in which I am passing a custom object from Flex to
> .NET is working fine.
> 2) In GetTitle method, where I am returning a custom object from .NET to
> Flex, I am getting undefined. (I have data in the database, for the same
> inputs, the method is working fine from an .aspx page, so its not that there
> is no data)
>  
> Is there something that I am missing out?
> MXML 
>  
> <?xml version="1.0" encoding="utf-8"?>
>  
> <mx:Application
> xmlns:mx="http://www.macromedia.com/2003/mxml";
>     backgroundColor="#FFFFFF"
>     initialize="initApp()">
>  
>     <mx:Script>
>         import RemoteTest.Title;
>  
>         var title:RemoteTest.Title;
>  
>         function initApp() {
>             title=new Title();
>                  }
>  
>         function addTitle() {
>             title.au_id=au_id.text;
>             title.title_id=title_id.text;
>             title.au_ord=Number(au_ord.text);
>             title.royaltyper=Number(royaltyper.text);
>             srv.addEmployee(title);
>         }
>  
> function getTitle() {
>   srv.getEmployee(au_id.text);
>   }
>  
>  function onGetData(event:Object):Void {
>    title = event.result;
>    title_id.text = title.title_id;
>  
>  }
>      </mx:Script>
>  
>     <mx:RemoteObject id="srv" source="RemoteTest.Sample">
>         <mx:method name="addEmployee"/>
>         <mx:method name="getEmployee" result = "onGetData(event)" />
>      </mx:RemoteObject>
>  
>     <mx:Form>
>  
>         <mx:FormItem label="au_id">
>             <mx:TextInput id="au_id"/>
>         </mx:FormItem>
>         <mx:FormItem label="title_id">
>             <mx:TextInput id="title_id"/>
>         </mx:FormItem>
>         <mx:FormItem label="au_ord">
>             <mx:TextInput id="au_ord"/>
>         </mx:FormItem>
>         <mx:FormItem label="royaltyper">
>             <mx:TextInput id="royaltyper"/>
>         </mx:FormItem>
>    <mx:FormItem>
>             <mx:Button label="Add Employee" click="addTitle()"/>
>         </mx:FormItem>
>  <mx:FormItem>
>             <mx:Button label="Get Employee" click="getTitle()"/>
>         </mx:FormItem>
>   </mx:Form>  
>  
> </mx:Application>
> ActionScript 
>  
> // ActionScript Document
> class RemoteTest.Title {
>  
>     public var au_id : String;
>     public var title_id : String;
>     public var au_ord : Number;
>     public var royaltyper : Number;
>  
>     static var registered=
> Object.registerClass("RemoteTest.Title", RemoteTest.Title);
> }
>  
> .NET class
>  
> 
> 
> usingSystem; 
> 
> usingFlashGateway.IO; 
> 
> usingSystem.Xml; 
> 
> usingSystem.Data; 
> 
> usingSystem.Data.SqlClient; 
> 
> usingSystem.IO; 
> 
> usingSystem.Text; 
> 
> usingSystem.Collections; 
> 
>  
> 
> namespaceRemoteTest 
> 
> {
> 
> 
> 
> public class Sample 
> 
> 
> 
> {
> 
> private SqlConnection conn; 
> 
> public void addEmployee(Title employee) 
> 
> {
> 
> conn =new SqlConnection("data source=dt1305-priyanka\\netsdk;
> database=pubs;uid=sa;pwd=welcome;");
> 
> conn.Open();
> 
> SqlCommand sqlcomm = new SqlCommand();
> 
> 
> 
> sqlcomm.Connection=conn;
> 
> sqlcomm.CommandType = CommandType.Text;
> 
> sqlcomm.CommandText = "INSERT INTO titleauthor
> (au_id,title_id,au_ord,royaltyper) VALUES('"+employee.au_id
> + "','" +employee.title_id +"',"+employee.au_ord +","+employee.royaltyper
> +")";
> 
> sqlcomm.ExecuteNonQuery();
> 
> }
> 
>  
> 
> publicTitle getEmployee(string au_id) 
> 
> {
> 
> conn =new SqlConnection("data source=dt1305-priyanka\\netsdk;
> database=pubs;uid=sa;pwd=welcome;"); 
> 
> conn.Open();
> 
> SqlCommand sqlcomm = new SqlCommand(); 
> 
> 
> 
> sqlcomm.Connection=conn;
> 
> sqlcomm.CommandType = CommandType.Text;
> 
> sqlcomm.CommandText = "SELECT * FROM titleauthor WHERE au_id ='" + au_id +
> "'";
> 
> SqlDataReader readerObj = sqlcomm.ExecuteReader();
> 
> Title title = new Title(); 
> 
> while (readerObj.Read()) 
> 
> {
> 
> title.au_id = au_id;
> 
> title.title_id = readerObj.GetString(1);
> 
> title.au_ord = (System.Byte)readerObj.GetValue(2);
> 
> title.royaltyper = (Int32)readerObj.GetValue(3);
> 
> }
> 
> return title; 
> 
> }
> 
> }
> 
> }
> DataObject class in .NET
>  
> 
> 
> usingSystem; 
> 
> namespaceRemoteTest 
> 
> {
> 
> 
> 
> [Serializable]
> 
> public class Title 
> 
> {
> 
> public string au_id; 
> 
> public string title_id; 
> 
> public int au_ord; 
> 
> public int royaltyper; 
> 
> }
> 
> }
> Regards
> Priyanka
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> --
> Flexcoders Mailing List
> FAQ:
> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com 
> 
> 
> 
> SPONSORED LINKS 
> Computer software testing Macromedia flex Development 
> Software developer 
> ________________________________
> YAHOO! GROUPS LINKS 
> 
>  Visit your group "flexcoders" on the web.
>   
>  To unsubscribe from this group, send an email to:
>  [EMAIL PROTECTED]
>   
>  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
>  To unsubscribe from this group, send an email to:
>  [EMAIL PROTECTED]
>   
>  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
>  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
> ________________________________
> 
> 
>


------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12h7i3rvq/M=362335.6886445.7839731.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123086564/A=2894361/R=0/SIG=13jmebhbo/*http://www.networkforgood.org/topics/education/digitaldivide/?source=YAHOO&cmpgn=GRP&RTP=http://groups.yahoo.com/";>In
 low income neighborhoods, 84% do not own computers. At Network for Good, help 
bridge the Digital Divide!</a>.</font>
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to