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;
}
Rijwan AnsariPosted Jun 11, 2021, 9:31 AM
Sachin SinghPosted Jun 11, 2021, 8:32 AM
Cis PaPosted Jun 11, 2021, 2:50 AM
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
}
Sachin SinghPosted Jun 10, 2021, 10:15 AM