How to call update function of web service from web application

xrust

New Member
I have a web service function which is to update my database. I would like to call it from my web application but it won't work. It can be update through my web service but not my web application after I have call my web service. Is my code of calling the service function correct?Here is my web service update function : \[code\][WebMethod(EnableSession = true)]public string sell_item(string name, string photo, string description, string initial_price, string bid_time){ SqlConnection con = new SqlConnection("Data Source=USER-PC;Initial Catalog=Bidding;Integrated Security=True"); con.Open(); SqlCommand cmd = new SqlCommand("UPDATE login SET name = @name, photo = @photo, description = @description, initial_price = @initial_price, bid_time = @bid_time where username='"+ Session["username"] +"'", con); cmd.Parameters.AddWithValue("@name", name); cmd.Parameters.AddWithValue("@photo", photo); cmd.Parameters.AddWithValue("@description", description); cmd.Parameters.AddWithValue("@initial_price", initial_price); cmd.Parameters.AddWithValue("@bid_time", bid_time); cmd.ExecuteNonQuery(); con.Close(); return "Product has been upload successfully!";}\[/code\]This is my web application code that call the function: \[code\]public partial class bidpage : System.Web.UI.Page{abc.Service a = new abc.Service();protected void Page_Load(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e){ Label1.Text = Convert.ToString(a.sell_item(Convert.ToString(TextBoxProduct.Text), Convert.ToString(TextBoxPhoto.Text), Convert.ToString(TextBoxDescription.Text), Convert.ToString(TextBoxPrice.Text), Convert.ToString(TextBoxBidTime.Text)));}\[/code\]}
 
Back
Top