look man i don't understand becuase i need to see the code but let me help you:
1st- user WCF it is more professional than web-service and also it is a kind of web service you can do that by right click on your solution -> Add --> New Project -> go to Web under Visual C# and add new asp.net empty web application
2nd- right click on this new web app -> add -> New Item also go to web under visual C# and choose WCF Service and add it and don'y forget to build it the go to your phone project right click add service reference click Discover after the the text box address will be filled with the path of the WCF automatically then press ok but dont forget when you change anything in the WCF you have to update the service by right on youServiceNameservicereference under service reference right click update
3rd- in the Iservice1.CS you have to add your class as follows :
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetItemInfo(string Category);
}
[DataContract]
public class Items
{
public string ID { get; set; }
public string Category { get; set; }
public string Info { get; set; }
public int Quantity { get; set; }
public string Mark { get; set; }
public int Price { get; set; }
}
and in the IService1.svc.cs add the function ass follows:
public class Service1 : IService1
{
string connection = ConfigurationManager.ConnectionStrings["Connection"].ToString();
public string GetItemInfo(string Category)
{
Items items = new Items();
SqlDataReader reader = null;
SqlCommand cmd = new SqlCommand("select top(1) ID, Category, Info, Mark, Quantity, Price from item where category ='" + Category + "'");
SqlConnection conn = new SqlConnection(connection);
conn.Open();
cmd.Connection = conn;
reader = cmd.ExecuteReader();
if (reader.Read())
{
items = new Items();
items.ID = (string)reader["ID"];
items.Category = reader["Category"].ToString().Trim();
items.Info = reader["info"].ToString().Trim();
items.Mark = reader["Mark"].ToString().Trim();
items.Quantity = Convert.ToInt16(reader["Quantity"]);
items.Price = Convert.ToInt16(reader["Price"]);
}
conn.Close();
return items.Info;
}
}
4th- in the code behind of your page use the function ass follows:
private void btnFind_Click(object sender, RoutedEventArgs e)
{
Service1Client service = new Service1Client();
service.GetItemInfoAsync(txt1.Text);
service.GetItemInfoCompleted += new EventHandler<GetItemInfoCompletedEventArgs>(service_GetItemInfoCompleted);
}
void service_GetItemInfoCompleted(object sender, GetItemInfoCompletedEventArgs e)
{
txb1.Text = e.Result;
}
don't forget when you make changes in the service update the service reference in the mobile application.
best regards and don't forget to vote if this help you.