title: MVC - For Loop - Add addition variable
body: <p>im working on a project in mvc4 visual studio and have add an Uploadhandler.ashx.cs to upload the files.</p>
  
  <p>the code is working to upload the files and insert into the information into my database.</p>
  
  <p>Now what i try/need:</p>
  
  <p>i have add a column where i want insert a number of each row like 1, 2 ,3, 4 etc...</p>
  
  <p>in my code i have a for loop to do what i want for each file.</p>
  
  <p>How can i generate a variable which add automatically +1 to insert it into my database.</p>
  
  <p>i have try a lot of things like:</p>
  
  <pre><code>var a=1;
  
  for(.......)
  {
  
  /*******My code****************/
  
  a=a+1;
  }
  </code></pre>
  
  <p>Hope that someone can give a hand with this:</p>
  
  <p>here is my code:</p>
  
  <pre><code> private void UploadWholeFile(HttpContext context, List&lt;FilesStatus&gt; statuses)
          {
              using (SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
              {
                  var a= 1;
  
                  for (int i = 0; i &lt; context.Request.Files.Count; i++)
                  {
                      var file = context.Request.Files[i];
  
                      var fullpath = "/Files/"  + Path.GetFileName(file.FileName);
  
                      var myfilename=Path.GetFileName(file.FileName);
  
                      file.SaveAs(fullpath);
  
                      statuses.Add(new FilesStatus(fullName, file.ContentLength, fullpath 
  
                      string sql1 = "insert into Image(FileName, Number) values (@FileName, @Number)";
  
                      using (SqlCommand cmd = new SqlCommand(sql1, cn))
                      {  
                          cmd.Parameters.AddWithValue("@FileName", myfilename);
                          cmd.Parameters.AddWithValue("@Number", a);
                          cn.Open();
                          cmd.ExecuteNonQuery();
                          cn.Close();
                      }
  
                      a = a + 1;
                  }
              }
          }
  </code></pre>