Wednesday, February 23, 2011

Web Service call with a String as a parameter

ASP.NET Web Service ( ASMX ) call from Android with a String parameter :

http://www.flickr.com/photos/24834074@N04/5469116121/sizes/l/in/photostream/

http://www.flickr.com/photos/24834074@N04/5469710588/sizes/l/in/photostream/
http://www.flickr.com/photos/24834074@N04/5469116261/sizes/l/in/photostream/
http://www.flickr.com/photos/24834074@N04/5469710484/sizes/l/in/photostream/


[WebMethod(Description = "Method to obtain Orders By Zone")]
public Order[] ReturnOrdersByZone(string theZone)
{

    SqlConnection dbConn = new SqlConnection(connStr);
    dbConn.Open();

    string sqlSelect = " SELECT TOP (100) dbo.PersoanaFizica.Nume as Name , dbo.PersoanaFizica.Prenume as Surname, dbo.Zona.Denumire AS Zone, dbo.Persoana.Denumire AS Client , dbo.[Document].Control " +
" FROM dbo.[Document] INNER JOIN " +
" dbo.PersoanaFizica ON dbo.[Document].Utilizator_ID =
dbo.PersoanaFizica.PersoanaFizica_ID INNER JOIN " +
 " dbo.Persoana ON dbo.[Document].Persoana_ID = dbo.Persoana.PersoanaID INNER JOIN " +
 " dbo.Comanda ON dbo.[Document].DocumentID = dbo.Comanda.Comanda_ID INNER JOIN  " +
 " dbo.Utilizator ON dbo.[Document].Utilizator_ID = dbo.Utilizator.UtilizatorID INNER JOIN " +
                   " dbo.Zona ON dbo.Utilizator.ZonaID = dbo.Zona.Id " +
                   " WHERE  (dbo.Zona.Denumire LIKE" + "'%" + theZone + "%')" +
                   " ORDER BY Control DESC ";


    SqlDataAdapter da = new SqlDataAdapter(sqlSelect, dbConn);
    DataTable dt = new DataTable();
    SqlCommand dbCommand = new SqlCommand(sqlSelect, dbConn);
    da.Fill(dt);
    dbConn.Close();
    List list = new List();
    foreach (DataRow row in dt.Rows)
    {
        // Person target = Activator.CreateInstance();
        Order target = new Order();
        target.Name = row["Name"].ToString();
        target.Surname = row["Surname"].ToString();
        target.Zone = row["Zone"].ToString();
        target.Client = row["Client"].ToString();
        target.Control = row["Control"].ToString();
        list.Add(target);
    }
    return list.ToArray();
}

No comments:

Post a Comment