title: Index (zero based) in sql query in c#
body: <p>I don't understand this error in this sql query.</p>
  
  <p>The error is </p>
  
  <blockquote>
    <p>Index (zero based) must be greater than or equal to zero</p>
  </blockquote>
  
  <p>My code c# in error this is :</p>
  
  <pre><code>        sql = @String.Format(" UPDATE `tbl_csv` ");
          sql += String.Format(" SET ");     
          sql += String.Format(" xAAA = 1, ");            
          sql += String.Format(" xBBB = {0},  ");
          sql += String.Format(" xCCC = {1},  ");
          sql += String.Format(" xDDD = {2} ");           
          sql += String.Format(" WHERE Id IN ({3}); ",
              ddlBBB.SelectedValue.ToString(),
              ddlCCC.SelectedValue.ToString(),
              ddlDDD.SelectedValue.ToString(),
              Base64ForUrlDecode(Request.QueryString["sId"].ToString()));
  </code></pre>
  
  <p>But If try this diiferent version of sql query I don't have error and the output of query is correct:</p>
  
  <pre><code>        sql = @String.Format(" UPDATE `tbl_csv` ");
          sql += String.Format(" SET ");     
          sql += String.Format(" xAAA = 1, ");            
          sql += String.Format(" xBBB = '" + ddlBBB.SelectedValue.ToString() + "',  ");
          sql += String.Format(" xCCC = '" + ddlCCC.SelectedValue.ToString() + "',  ");
          sql += String.Format(" xDDD = '" +  ddlDDD.SelectedValue.ToString() + "' ");            
          sql += String.Format(" WHERE Id IN (" + Base64ForUrlDecode(Request.QueryString["sId"].ToString()) + "); ",
              ddlBBB.SelectedValue.ToString(),
              ddlCCC.SelectedValue.ToString(),
              ddlDDD.SelectedValue.ToString(),
              Base64ForUrlDecode(Request.QueryString["sId"].ToString()));
  </code></pre>
  
  <p>Output :</p>
  
  <pre><code>UPDATE `tbl_csv`
  SET xAAA = 1,
   xBBB = 'N',
   xCCC = 'N',
   xDDD = 'N'
  WHERE
      Id IN ('2357');
  </code></pre>
  
  <p>How to do resolve this?</p>
  
  <p>Can you help me?</p>
  
  <p>Thank you in advance for any help, really appreciated.</p>