title: SQL bulk insert does not insert values properly into table
body: <p>I have an Excel file(.xlsx) and I am trying to upload the content of the file into a Sql server table. Iam using the SQL bulk copy to bulk insert the data. The data gets inserted into the table but I find that the data is not inserted properly.</p>
  <p>Here is the sample Excel data-</p>
  <p><img src="https://i.stack.imgur.com/fhfsX.jpg" alt="enter image description here" /></p>
  <p>This is the code for Sql bulk copy:</p>
  <pre><code>string fname = Path.GetFileName(fup_addRoute.FileName);
  fup_addRoute.SaveAs(Server.MapPath(&quot;/Admin/UserRoutes/&quot; + fname));
  string path = Server.MapPath(&quot;/Admin/UserRoutes/&quot; + fname);
                      
  using (OleDbConnection connection = new OleDbConnection(string.Format(&quot;Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 8.0&quot;, path)))
  {
        OleDbCommand command = new OleDbCommand(&quot;select * from [Sheet1$]&quot;, connection);
        connection.Open();
        System.Data.Common.DbDataReader dr = command.ExecuteReader();
        SqlBulkCopy bulkInsert = new SqlBulkCopy(con); 
        bulkInsert.DestinationTableName = &quot;routesdata&quot;;
        bulkInsert.WriteToServer(dr);
        connection.Close();
        dr.Close();
        bulkInsert.Close();
  }
  </code></pre>
  <p>Data after insert:</p>
  <p><img src="https://i.stack.imgur.com/aL9jv.jpg" alt="enter image description here" /></p>
  <p>Only last row gets inserted and the first column value in excel sheet is missing. The xid column in table is an auto-increment column.</p>
  <p>This procedure was easy in MySql with 'load data infile' but I just migrated to Sql server. What am I doing wrong in my code. Suggestions please.</p>