I have a flex DBGrid client that was supposed to consume a web 
service client. After much tweaking and coding. No success. I 
switched to HTTPService and this was returning xml results.
But when DBGrid accepts the results they are all listed ONLY in row 1 
of the DBGrid.
Below is the mxml application as well as the web service I 1st used 
and finally the httpservice routine done in C# 2.0
Any help will be appreciated.
Thanks.

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
layout="absolute">
<mx:HTTPService id="SDSearch" 
url="http://localhost:53541/SDSearch.NET/Default.aspx"; 
showBusyCursor="true">
<mx:request>
        <byName>{NameBox.text}</byName>
        <byPhoneNum>{PhoneBox.text}</byPhoneNum>
</mx:request>
        
</mx:HTTPService>
        <mx:DataGrid enabled="true" id="dataGrid" editable="false" 
x="130" y="179" width="411" height="273" 
dataProvider="{SDSearch.lastResult.STAFFREC}" 
alternatingItemColors="[#fcf7e4, #ffffff]">
                <mx:columns>

                        <mx:DataGridColumn headerText="Staff Name" 
dataField="STAFFNAME"/>
                        <mx:DataGridColumn headerText="Phone Number" 
dataField="PHONE_NUMBER"/>

                </mx:columns>
        </mx:DataGrid>
        <mx:Label x="28" y="88" text="Enter Name:"/>
        <mx:Label x="28" y="131" text="Enter Phone No:"/>
        <mx:TextInput id="NameBox" x="144" y="86" width="382"/>
        <mx:TextInput id="PhoneBox" x="144" y="129" width="382"/>
        <mx:Button x="247" y="530" label="Invoke Service" 
click="SDSearch.send();"/>      
        
</mx:Application>




public class Employee
{
    public string STAFFNAME;
    public string Phone_Num;
}
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
            string byName, byPhoneNum;
            string queryString, cnString;
            OleDbDataAdapter adapter;
            DataSet EmpData = new DataSet();
            cnString = ConfigurationManager.AppSettings
["ConnStrDB"].ToString();

            byName = Request.Params["byName"].ToString().Trim();
            byPhoneNum = Request.Params["byPhoneNum"].ToString().Trim
();

            if (byPhoneNum.Length == 11)
            {
                queryString = "SELECT * FROM Employees WHERE 
PHONE_NUMBER = '" + byPhoneNum + "'";
                adapter = new OleDbDataAdapter(queryString, cnString);
                adapter.Fill(EmpData, "Employees");

                Response.Write("<STAFFREC>");
                foreach (DataRow currrec in EmpData.Tables[0].Rows)
                {
                    Response.Write("<STAFFNAME>" + currrec
["STAFFNAME"].ToString() + "</STAFFNAME>");
                    Response.Write("<PHONE_NUMBER>" + currrec
["PHONE_NUMBER"].ToString() + "</PHONE_NUMBER>");
                }
                Response.Write("</STAFFREC>");
                //XmlDataDocument dataDoc = new XmlDataDocument
(EmpData);
                //return dataDoc;
            }
            else 
            {
                queryString = "SELECT * FROM Employees WHERE 
STAFFNAME LIKE '%" + byName + "%'";
                adapter = new OleDbDataAdapter(queryString, cnString);
                adapter.Fill(EmpData, "Employees");

                Response.Write("<STAFFREC>");
                foreach (DataRow currrec in EmpData.Tables[0].Rows)
                {
                    Response.Write("<STAFFNAME>" + currrec
["STAFFNAME"].ToString() + "</STAFFNAME>");
                    Response.Write("<PHONE_NUMBER>" + currrec
["PHONE_NUMBER"].ToString() + "</PHONE_NUMBER>");
                }
                Response.Write("</STAFFREC>");
                
                //XmlDataDocument dataDoc = new XmlDataDocument
(EmpData);
                //return dataDoc;
            }
    }
}


// the web service..
[WebService(Namespace = "http://tempuri.org/";)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Employee
{
    public string STAFFNAME;
    public string Phone_Num;
}
public class SDSearch : System.Web.Services.WebService
{
    public SDSearch () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public XmlDataDocument getStaffMatch(string byName, string 
byPhoneNum)
    {
        string queryString,cnString;
        OleDbDataAdapter adapter;
        DataSet EmpData = new DataSet();
        cnString = ConfigurationManager.AppSettings
["ConnStrDB"].ToString();
        
        if (byPhoneNum.Length == 11)
        {
            queryString = "SELECT * FROM Employees WHERE PHONE_NUMBER 
= '" + byPhoneNum + "'";
            adapter = new OleDbDataAdapter(queryString, cnString);
            adapter.Fill(EmpData,"Employees");
            XmlDataDocument dataDoc = new XmlDataDocument(EmpData);
            return dataDoc;
        }
        else //if (byName.Length > 3)
        {
            queryString = "SELECT * FROM Employees WHERE STAFFNAME 
LIKE '%" + byName + "%'";
            adapter = new OleDbDataAdapter(queryString, cnString);
            adapter.Fill(EmpData, "Employees");
            XmlDataDocument dataDoc = new XmlDataDocument(EmpData);
            return dataDoc;
        }

    }
    
}


Reply via email to