title: Getting parameter in ADO.Net exception when calling from angular
body: <p>I had created an API in Dot net core. When I had tested it's working well &amp; good through postman or ARC tools. But when calling from angular, It's throwing an sqlexception like : &quot;An SqlParameter with parameter name @TotalRows is not contained by the SqlParameterCollection.&quot;
  My wonder is how it's working in postman &amp; why not in angular call.
  My API dataaccess is like below :</p>
  <pre><code>public List&lt;PoDetails&gt; GetPoDetails(PoDetails pods, string vendor_id, out int TotalRows, int Timezone)
          {
              List&lt;PoDetails&gt; posList = new List&lt;PoDetails&gt;();
              TotalRows = 0;
              try
              {
                  con = new SqlConnection(conString);
                  cmd = new SqlCommand(&quot;sp_cc_get_po_details&quot;, con);
                  cmd.Parameters.Clear();
                  cmd.CommandType = CommandType.StoredProcedure;
                  cmd = Util.AddConditionalParameterString(cmd, &quot;@vendor_id&quot;, vendor_id);
                  cmd = Util.AddConditionalParameterString(cmd, &quot;@sortBy&quot;, pods.sortBy);
                  cmd = Util.AddConditionalParameterString(cmd, &quot;@sortDirection&quot;, pods.sortDirection);
                  cmd = Util.AddConditionalParameterInt(cmd, &quot;@pageSize&quot;, pods.pageSize);
                  cmd = Util.AddConditionalParameterInt(cmd, &quot;@page&quot;, pods.page);
                  cmd = Util.AddConditionalParameterInt(cmd, &quot;@time_zone_offset&quot;, Timezone);
  
                  cmd.Parameters.Add(new SqlParameter(&quot;@TotalRows&quot;, SqlDbType.Int));
                  cmd.Parameters[&quot;@TotalRows&quot;].Direction = ParameterDirection.Output;
  
                  SqlDataAdapter da = new SqlDataAdapter(cmd);
  
                  DataTable dt = new DataTable();
                  da.Fill(dt);
                  TotalRows = Convert.ToInt32(cmd.Parameters[&quot;@TotalRows&quot;].Value);
  
                  foreach (DataRow dr in dt.Rows)
                  {
                      PoDetails posobj = new PoDetails();
  
                      posobj.vendor_name = dr[&quot;vendor_name&quot;].ToString();
                      posobj.create_date = Convert.ToDateTime(dr[&quot;create_date&quot;].ToString());
                      posobj.po_id = Convert.ToInt32(dr[&quot;po_id&quot;]);
                      posobj.po_amount = Convert.ToInt32(dr[&quot;po_amount&quot;]);
                      posobj.invoice_count = Convert.ToInt32(dr[&quot;invoicecount&quot;]);
                      if (dr[&quot;utilization_amount&quot;] != DBNull.Value)
                          posobj.utilization_amount = Convert.ToInt32(dr[&quot;utilization_amount&quot;]);
                      else
                          posobj.utilization_amount = 0;
  
                      posList.Add(posobj);
                  }
              }
              catch (Exception ec)
              {
                  throw new Exception(ec.Message);
              }
              return posList;
          }
  </code></pre>
  <p>My procedure was like below :</p>
  <pre><code>ALTER PROCEDURE [dbo].[sp_cc_get_po_details] 
  ( 
      @vendor_id              varchar(100) = null, 
  
      @sortBy             varchar(50)     = NULL,
      @sortDirection      varchar(50)     = null,
      @pageSize               int             = NULL,
      @page                   int             = NULL,
      @TotalRows              int             = NULL output,
      @time_zone_offset       int           = 0
    ) 
  AS
  BEGIN
  
    SELECT Count(I.invoice_id) as invoicecount, p.po_id,p.po_amount,p.vendor_id,
    DATEADD(MINUTE, @time_zone_offset, p.create_date) AS create_date , 
    v.vendor_name, sum(I.invoice_amount) as utilization_amount
      into #TempResults
      FROM  po_details p left join  invoice_details I on p.po_id = I.po_id
  join vendor_details v on v.vendor_id = p.vendor_id
      WHERE (@vendor_id is null or @vendor_id = '' or v.vendor_id = @vendor_id)
      group by p.po_id, p.po_amount, p.vendor_id, p.create_date, v.vendor_name
  
  
      -- Paging Logic --
      Declare @StartingRow as int = 0
      Declare @FirstRow as int
      Declare @LastRow as int
      
      select  @TotalRows = count(*)
          from    #TempResults
      
      set @StartingRow = (@pageSize * @page) + 1
  
      if @pageSize is not null and @page is not null begin
          set @FirstRow = ((@page - 1) * @pageSize) + 1
          set @LastRow = @FirstRow + (@pageSize - 1)
      end else if @pageSize is not null and @StartingRow is not null begin
          set @FirstRow = @StartingRow
          set @LastRow = @FirstRow + (@pageSize - 1)
      end else begin
          set @FirstRow = 0
          set @LastRow = @TotalRows
      end
      ------
      -------------------
      
      --select @FirstRow;
      --select @LastRow;
  
      Select * from
      (
          Select ROW_NUMBER() over
          (
              order by
                  case when @sortBy = 'vendor_id'   and   @sortDirection = 'desc' then vendor_id end desc,
                  case when @sortBy = 'vendor_id'   and   @sortDirection = 'asc' then vendor_id end asc,
                  case when @sortBy = 'vendor_name' and   @sortDirection = 'desc' then vendor_name end desc,
                  case when @sortBy = 'vendor_name' and   @sortDirection = 'asc' then vendor_name end asc,
                  vendor_id
          ) as RowNumber, * from #TempResults
      ) RowData
      where   RowNumber between @FirstRow and @LastRow
      order by RowNumber
  
  
      
  end
  
      
  </code></pre>