Last post Aug 21, 2014 02:16 AM by tonyR6
Aug 19, 2014 05:00 AM|tonyR6|LINK
here is my code which I'm using
<WebMethod(Description:="Returns the Price and the Product Code")> _
Public Function Get_Price(ByVal weight As String) As String
'' Dim price As String
Dim PCode As New Product()
''Dim PCode As String
Dim xml As XElement = XElement.Load("~\eb.xml")
Dim query1 = (From d In xml.Elements()
Where Convert.ToInt32((d.Attribute("_ID").Value)) >= Convert.ToInt32(weight)
PCode.Price_ID = query1.Element("AMOUNT").Value.ToString()
PCode.Product_Code = query1.Element("Product_Code").Value.ToString()
Im getting error on PCode which says
Value of type 'WebApplication2.Etailer.Product' cannot be converted to 'String'.
Aug 19, 2014 05:14 AM|SSA|LINK
Your method return type is String and your are returing a class i.e. Product hence the error. You need to return product.
Public Function Get_Price(ByVal weight As String) As Product
Also note that your class should be serializable.
Aug 19, 2014 05:14 AM|AidyF|LINK
Your function returns a string, yet you are returning an object of type Product....what exactly are you expecting to see returned? If you are looking to serialise the object then change the return type of your function from string to Product. If you are
only interested in a single property of the product then return just that property rather than the whole object
Aug 21, 2014 02:16 AM|tonyR6|LINK
Thanx guys it worked