Hi all,
I have stored procedure that will update multiple tables and returnedvalue as 1.The parameters are passed through the Client application.
Here i updated the tables in DB so do i need to use PUT verb in my REST web api to call the SP and how to consume using PUT httpclient?
plz help
[HTTPPUT]
public IHttpActionResultUpdateDB(string id,string name,string city,string country )
{
int ReturnValue = 0;
SqlCommand cmd = new SqlCommand("SP_UPDATED", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
SqlParameter ret = new SqlParameter();
ret.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.AddWithValue("@id", id);
cmd.Parameters.AddWithValue("@name", name);
cmd.Parameters.AddWithValue("@city", city);
cmd.Parameters.AddWithValue("@country", country);
ret.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(ret);
cmd.ExecuteNonQuery();
try
{
con.Open();
cmd.ExecuteNonQuery();
con.Close();
ReturnValue = (int)ret.Value;
}
catch (Exception ex)
{}
return ReturnValue;
}

Sachin SinghRank #66 · 26.2K reputationPosted Jun 11, 2021, 4:32 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 10, 2021, 6:15 AM EDT
Cis PaRank #9,026 · 212 reputationPosted Jun 10, 2021, 10:50 PM EDT
hi,
Tried your code and getting 405 method not found error, i checked the route and seems ok.How do i pass the parameters through the URL? httpResponseMessage = await client.PutAsync("http://localhost/WebAPI/api/start/SetUpdate", content);
[HTTPPUT]
public IHttpActionResult UpdateDB(int id,string name,string city,string country,int streetcode )
{
return 1
}
Rijwan AnsariRank #82 · 24.2K reputationPosted Jun 11, 2021, 5:31 AM EDT