You execute the method WriteToServer, and the following error is thrown:
The DestinationTableName property must be set before calling this method.
// Oops! The destination name is empty
string destinationName = "";
using(var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServer()))
{
connection.Open();
using (var sqlBulk = new SqlBulkCopy(connection))
{
sqlBulk.DestinationTableName = destinationName;
sqlBulk.WriteToServer(dt);
}
}
string destinationName = "Customers";
using(var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServer()))
{
connection.Open();
using (var sqlBulk = new SqlBulkCopy(connection))
{
sqlBulk.DestinationTableName = destinationName;
sqlBulk.WriteToServer(dt);
}
}