Cis Pa

Cis Pa

  • NA
  • 194
  • 23k

how to use Ref Parameter in REST Web API

Jun 14 2021 9:38 AM

Hi 

How to pass ref parameter through HTTP Get method in Rest Web api and get the result in postman.

How to return the no of records as well as Dataset in Rest Web api.plz help.

public JsonResult<DataSet> GetRecords(string Code,ref int noofrecords
{
    DataSet ds = new DataSet();
    try
    {
        SqlDataAdapter da = new SqlDataAdapter("GetRecords", con);
        con.Open();
        da.SelectCommand.CommandType = CommandType.StoredProcedure;
        SqlParameter ret = new SqlParameter();
        ret.Direction = ParameterDirection.ReturnValue;
        da.SelectCommand.Parameters.Add("@Code", SqlDbType.VarChar, 20).Value = Code;
        da.SelectCommand.Parameters.Add(ret);
        da.Fill(ds, "StudentList");
        noofrecords = (int)ret.Value;
    } 
    catch (Exception)  {   
    }
    return Json(ds);
} 

Answers (2)