title: The given value of type String from the data source cannot be converted to type int of the specified target column
body: <p>I am trying to read values from xml file and then use the bulkcopy to insert the data into my database.</p>
  
  <p>I am using a custom class which is:</p>
  
  <pre><code>class Customer
      {
          public int CustomerID { get; set; }
          public string FirstName { get; set; }
          public string LastName { get; set; }
          public int ShowsNumber { get; set; }
          public int VisitNumber { get; set; }
          public int Cancellation { get; set; }
      }
  </code></pre>
  
  <p>and I read the data like this:</p>
  
  <pre><code>List&lt;Customer&gt; customersList =
                  (
                      from e in XDocument.Load(file).Root.Elements("cust")
                      select new Customer
                      {
                          CustomerID = (int)e.Attribute("custid"),
                          FirstName = (string)e.Attribute("fname"),
                          LastName = (string)e.Attribute("lname"),
                          ShowsNumber = (int)e.Attribute("count_noshow"),
                          VisitNumber = (int)e.Attribute("count_resos"),
                          Cancellation = (int)e.Attribute("count_cancel"),
                      }).ToList();
  </code></pre>
  
  <p>Then I insert that <code>customersList</code> to a datatabe like this:</p>
  
  <pre><code>DataTable dataTable = getBasicDataTable();
  for (int i = 0; i &lt; customersList.Count; i++)
                  {
                      DataRow datarows = dataTable.NewRow();
                      datarows[0] = customersList[i].CustomerID;
                      datarows[1] = customersList[i].FirstName;
                      datarows[2] = customersList[i].LastName;
                      datarows[3] = customersList[i].ShowsNumber;
                      datarows[4] = customersList[i].VisitNumber;
                      datarows[5] = customersList[i].Cancellation;
                      dataTable.Rows.Add(datarows);
                  }
  </code></pre>
  
  <p>then I insert the data to my database like this:</p>
  
  <p>but I got this exception</p>
  
  <pre><code>using (SqlBulkCopy sbc = new SqlBulkCopy(GetConnectionString()))
              {
                  sbc.DestinationTableName = XMLReader.databaseTable;
                  sbc.WriteToServer(dataTable);
              }
  </code></pre>
  
  <blockquote>
    <p>The given value of type String from the data source cannot be converted to type int of the specified target column.</p>
  </blockquote>
  
  <p>as you see, when I extract the data from my xml, I already use the cast to <code>int</code> and to <code>string</code> and it is working. so why when inserting to the database I got that exception?</p>
  
  <h3>Note</h3>
  
  <p>In order to give you the whole code, this is the <code>getBasicDataTable</code> fuction</p>
  
  <pre><code>private DataTable getBasicDataTable()
          {
              DataTable dataTable = new DataTable();
              dataTable.Clear();
              dataTable.Columns.Add("customerID");
              dataTable.Columns.Add("firstName");
              dataTable.Columns.Add("lastName");
              dataTable.Columns.Add("showsNumber");
              dataTable.Columns.Add("visitNumber");
              dataTable.Columns.Add("cancellation");
              return dataTable;
          }
  </code></pre>