string connectionString= ServerName + DatabaseName + SecurityType;
using (SqlConnection connection = new SqlConnection(connectionString))
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connection)) {
connection.Open();
bulkCopy.DestinationTableName = "TableName";
try {
bulkCopy.WriteToServer(dataTableName);
} catch (Exception e) {
Console.Write(e.Message);
}
}
Please note that the structure of the database table and the table name should be the same or it will throw an exception.