Logesh Kumar

Logesh Kumar

  • 1.5k
  • 243
  • 31.5k

Consume WCF service into Web Application

Feb 28 2019 1:03 AM
Here it's my  Code (WCF Service Insert Operation)
 
how to Insert In an web Application  (How to Consume WCF Service to Web Application)
 
public List<sResponse> mstrConfigurationType(mstrConfigurationType Type)
{
string sReturn = string.Empty;
List<sResponse> objS = new List<sResponse>();
try
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ConnectionString);
SqlCommand cmd = new SqlCommand
("ConfigurationType", con);//ProcedureName(ConfigurationType)
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@QueryType", "Insert");
cmd.Parameters.AddWithValue("@TypeId", Type.TypeId);
cmd.Parameters.AddWithValue("@TypeName", Type.TypeName);
cmd.Parameters.AddWithValue("@ActiveStatus", Type.ActiveStatus);
cmd.Parameters.AddWithValue("@CreatedBy", Type.CreatedBy);
SqlParameter RuturnValue = new SqlParameter("@SQLReturn", SqlDbType.VarChar, 50);
RuturnValue.Direction = ParameterDirection.Output;
cmd.Parameters.Add(RuturnValue);
con.Open();
cmd.ExecuteNonQuery();
sReturn = cmd.Parameters["@SQLReturn"].Value.ToString();
//string[] sResult = sReturn.Split('~');
con.Close();
if (sReturn.Trim() == "Success")
{
objS.Add(new sResponse()
{
Status = "Ok",
Response = sReturn
});
return objS;
}
else if (sReturn.Trim() == "Already")
{
objS.Add(new sResponse()
{
Status = "Og",
Response = sReturn
});
return objS;
}
else
{
objS.Add(new sResponse()
{
Status = "Bad-request",
Response = sReturn
});
return objS;
}
}
catch (Exception ex)
{
objS.Add(new sResponse()
{
Status = "Bad-request",
Response = ex.Message
});
return objS;
}
}
 
 
 

Answers (1)