title: "The given ColumnMapping does not match up with any column in the source or destination" when uploading csv to sql server
body: <p>I am trying to upload CSV to SQL server by transforming the CSV to Datatable then this Datatable to be inserted into SQL data server. The CSV is read correctly into Datatable but while inserting the data to SQL this error occurs </p>
  
  <blockquote>
    <p>"The given Column Mapping does not match up with any column in the
    source or destination"</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>static void InsertDataIntoSQLServerUsingSQLBulkCopy(DataTable csvFileData)
      {
          System.IO.File.Create("C:\\Users\\Rana\\Desktop\\inside.txt");
          using (SqlConnection dbConnection = new SqlConnection("Data Source=DESKTOP-N7OIK1O\\MSSQLSERVER02;Initial Catalog=nokia_Alarm;Integrated Security=SSPI;"))
          {
              System.IO.File.Create("C:\\Users\\Rana\\Desktop\\inside1.txt");
              dbConnection.Open();
              using (SqlBulkCopy s = new SqlBulkCopy(dbConnection))
              {
                  System.IO.File.Create("C:\\Users\\Rana\\Desktop\\inside2.txt");
                  s.DestinationTableName = "csv_Table";
  
                  foreach (var column in csvFileData.Columns)
                      s.ColumnMappings.Add(column.ToString(), column.ToString());
                  s.WriteToServer(csvFileData);
                  System.IO.File.Create("C:\\Users\\Rana\\Desktop\\inside4.txt");
              }
          }
      }
  </code></pre>
  
  <p>I do not know where the problem is ?</p>
  
  <p>is it in the DB connection ?</p>
  
  <blockquote>
    <p>(SqlConnection dbConnection = new SqlConnection("Data
    Source=DESKTOP-N7OIK1O\MSSQLSERVER02;Initial
    Catalog=nokia_Alarm;Integrated Security=SSPI)</p>
  </blockquote>