title: Tried to bind parameter number 0. SQL Server supports a maximum of 2100 parameters
body: <p>I'm currently using a PDO class that works on MySQL perfectly. But when it comes to MSSQL , I get an error when I try to insert data via the <code>bindValue()</code> function.</p>
  
  <p>I'm using this method for data binding:</p>
  
  <blockquote>
    <p><code>bindValue(":param",$value)</code></p>
  </blockquote>
  
  <h3>Step 1 - Create an array for the table fields in the query</h3>
  
  <pre><code>$counter = 0;
          foreach($fields as $cols)
          {
              $fieldBind[$counter] = ":".$cols;
              $new_f =  $new_f ."". $cols;
              $counter ++;
              if($counter!=count($fields))
              {
                  $new_f = $new_f.",";
              }
          }
  
  
  output : (
  [0] =&gt; :field1
  [1] =&gt; :field2
  [2] =&gt; :field3
  )
  </code></pre>
  
  <h3>Step 2 - Create an array for the data of the fields in the query</h3>
  
  <pre><code>$counter2 = 0;
          foreach($data as $cols)
          {
              $dataBind[$counter2] = $cols;
              $new_d =  $new_d."'".$cols."'";
              $counter2 ++;
              if($counter2!=count($data))
              {
                  $new_d = $new_d.",";
              }
          }
  
  output : ( [0] =&gt; value1 [1] =&gt; value2  [2] =&gt; value3 )
  </code></pre>
  
  <h3>Step 3 - Prepare the query via the <code>query</code> function</h3>
  
  <pre><code>parent::query("INSERT INTO $table($new_f) VALUES($new_d)");
  </code></pre>
  
  <h3>Step 4 - Bind the Parameters and Values</h3>
  
  <pre><code>for($i=0;$i&lt;count($data);$i++){
              parent::bind($fieldBind[$i],$dataBind[$i]);
          }
  </code></pre>
  
  <p>The query looks like this:</p>
  
  <pre><code>INSERT INTO table(field1,field2,field3) values(':value1',':value2',':value3')
  </code></pre>
  
  <h3>Step 5 - Execute the Query</h3>
  
  <pre><code>try { 
              parent::execute();
              return parent::rowCount();
              }
          catch(PDOException $e) {
              echo $e-&gt;getMessage();
          }
  </code></pre>
  
  <p>This method works perfectly on MySQL, but when I try to execute this on SQL Server, I get this error:</p>
  
  <p><strong>SQLSTATE[IMSSP]: Tried to bind parameter number 0. SQL Server supports a maximum of 2100 parameters.</strong></p>