title: bulkCopy.WriteToServer does not copy
body: <p>I'm trying to use <code>bulkCopy.WriteToServer()</code> to copy data from my remote SQL Server Express to my local SQL Server Express, but no data is ever written to my local SQL Server Express database. </p>
  
  <p>The code jumps over the <code>WriteToServer()</code> method instantly... I have no idea if it's failing on the inside and not showing an error message though</p>
  
  <p>I have read <a href="https://stackoverflow.com/questions/542296/how-to-duplicate-a-sql-server-2000-table-programatically-using-net-2-0">How to duplicate a SQL Server 2000 table programatically using .NET 2.0?</a> and I am using very similar code. Although I am using SQL Server 2008 Express on remote and a local to SQL Server 2014 Express:</p>
  
  <pre><code>using (SqlConnection remoteConnection = new SqlConnection(remoteConnectionString))
  {
      var query = "SELECT * FROM information_schema.tables WHERE table_type = 'base table'";
      SqlCommand commandGetTables = new SqlCommand(query, remoteConnection);
  
      try
      {
          remoteConnection.Open();
          SqlDataReader results = commandGetTables.ExecuteReader();
  
          while (results.Read())
          {
              tables.Add(results.GetString(2));
          }
  
          results.Close();
      }
      catch (Exception ex)
      {
          //stuff
      }
      finally
      {
          remoteConnection.Close();
      }
  
      remoteConnection.Open();
  
      foreach (var table in tables)
      {                    
          // Get data from the source table as a SqlDataReader.
          var commandSourceData = new SqlCommand("SELECT * FROM " + table + ";", remoteConnection);
          var reader = commandSourceData.ExecuteReader();
  
          using (SqlConnection destinationConnection = new SqlConnection(destinationConnectionString))
          {
              destinationConnection.Open();
  
              using (var bulkCopy = new SqlBulkCopy(destinationConnection))
              {
                  bulkCopy.DestinationTableName = table;
  
                  try
                  {
                      // Write from the source to the destination.
                      bulkCopy.WriteToServer(reader);
                  }
                  catch (Exception ex)
                  {
                      //stuff
                  }
                  finally
                  {
                      //stuff removed for this post
                  }
              }
          }
      }
  
      remoteConnection.Close();
  }
  return true;
  </code></pre>
  
  <p>I know this could be subject to SQL injection etc, but this app is only used by me and not the issue here.</p>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I checked the value of  reader (<code>var reader = commandSourceData.ExecuteReader();</code>) and it has entries as I would expect, meaning he reading from the remote is fine.</p>