title: SqlDataAdapter Output Variable Question C#
body: <p>I do not clearly understand how to format the <code>SqlDataAdapter</code> for output variables when working with C#</p>
  <p>Error Message:</p>
  <p>Index (zero based) must be greater than or equal to zero and less than the size of the argument list.</p>
  <p>Code Example (Stored Procedure works fine):</p>
  <pre><code>private DataTable updateOrdEodHold(DataTable tb, out string mnpft,
      out string authld, out string trd, out string hld, out string extnow)
  {
      // Start the connection string.
      string connstr = ConfigurationManager.ConnectionStrings
          [&quot;LocalSqlServer&quot;].ConnectionString;
      SqlConnection myConn = new SqlConnection(connstr);
      // Declare symbol and assign for Errors Catch Exception.
      string Symbol = &quot;&quot;;
      string sqlComm = &quot;dbo.UpdateOrdEodHold&quot;;
      DataTable HoldVals = new DataTable();
      SqlDataAdapter dataAdp = new SqlDataAdapter(sqlComm, myConn);
      dataAdp.SelectCommand.CommandType = CommandType.StoredProcedure;
      string ticker = (string)Convert.ToString(tb.Rows[0][&quot;Ticker&quot;]);
      // update Symbol for Catch ex
      Symbol = ticker.ToString();
      String company = (string)Convert.ToString(tb.Rows[0][&quot;Company&quot;]);
      String avgprofit = (string)Convert.ToString(tb.Rows[0][&quot;AvgProfit&quot;]);
      String extdte = (string)Convert.ToString(tb.Rows[0][&quot;ExitDate&quot;]);
      dataAdp.SelectCommand.Parameters.Clear();
      dataAdp.SelectCommand.Parameters.Add(new SqlParameter(&quot;@ticker&quot;,
          SqlDbType.VarChar, 10));
      dataAdp.SelectCommand.Parameters[&quot;@ticker&quot;].Value =
          (string)ticker.ToString();
      dataAdp.SelectCommand.Parameters.Add(new SqlParameter(&quot;@company&quot;,
          SqlDbType.VarChar, 25));
      dataAdp.SelectCommand.Parameters[&quot;@company&quot;].Value =
          (string)company.ToString();
      dataAdp.SelectCommand.Parameters.Add(new SqlParameter(&quot;@avgpft&quot;,
          SqlDbType.VarChar, 10));
      dataAdp.SelectCommand.Parameters[&quot;@avgpft&quot;].Value =
          (string)avgprofit.ToString();
      dataAdp.SelectCommand.Parameters.Add(new SqlParameter(&quot;@mnpft&quot;,
          SqlDbType.VarChar, 10));
      dataAdp.SelectCommand.Parameters[&quot;@mnpft&quot;].Direction =
          ParameterDirection.Output;
      dataAdp.SelectCommand.Parameters.Add(new SqlParameter(&quot;@authld&quot;,
          SqlDbType.VarChar, 6));
      dataAdp.SelectCommand.Parameters[&quot;@authld&quot;].Direction =
          ParameterDirection.Output;
      dataAdp.SelectCommand.Parameters.Add(new SqlParameter(&quot;@hld&quot;,
          SqlDbType.VarChar, 6));
      dataAdp.SelectCommand.Parameters[&quot;@hld&quot;].Direction =
          ParameterDirection.Output;
      dataAdp.SelectCommand.Parameters.Add(new SqlParameter(&quot;@trd&quot;,
          SqlDbType.VarChar, 6));
      dataAdp.SelectCommand.Parameters[&quot;@trd&quot;].Direction =
          ParameterDirection.Output;
      dataAdp.SelectCommand.Parameters.Add(new SqlParameter(&quot;@extnow&quot;,
          SqlDbType.VarChar, 6));
      dataAdp.SelectCommand.Parameters[&quot;@extnow&quot;].Direction =
          ParameterDirection.Output;
      dataAdp.SelectCommand.Parameters.Add(new SqlParameter(&quot;@extdte&quot;,
          SqlDbType.VarChar, 15));
      dataAdp.SelectCommand.Parameters[&quot;@extdte&quot;].Value =
          (string)extdte.ToString();
      dataAdp.Fill(HoldVals);
      mnpft = HoldVals.Rows[0][&quot;MinProfit&quot;].ToString();
      authld = HoldVals.Rows[0][&quot;AutoHold&quot;].ToString();
      trd = HoldVals.Rows[0][&quot;Trade&quot;].ToString();
      hld = HoldVals.Rows[0][&quot;Hold&quot;].ToString();
      extnow = HoldVals.Rows[0][&quot;ExitNow&quot;].ToString();
      return HoldVals;
  }
  </code></pre>