TrimTrailingSpaces

shaynes41shaynes41 Posts: 4
I can't seem to get the ComparisonOptions.TrimTrailingSpaces to work in the API.

When I use the UI and Check the "Trim Trailing Spaces" box on the options tab, my data compare comes up with all the data matching.

When I add the ComparisonOptions.TrimTrailingSpaces to my mapping options, the data compare comes up with the data mismatching. It seems like this option is not working. Below is the code I'm trying to run:
mappings.Add(tableMapping);

mappings.Options = new EngineDataCompareOptions(MappingOptions.Default, ComparisonOptions.TrimTrailingSpaces, SqlOptions.Default);             

Console.WriteLine("** Comparing Databases");

session.CompareDatabases(db1, db2, mappings);

Console.WriteLine("** Comparison Finished");
Any ideas?

Comments

  • You might want to try:

    mappings.Options = new EngineDataCompareOptions(
    MappingOptions.Default,
    ComparisonOptions.TrimTrailingSpaces | ComparisonOptions.Default,
    SqlOptions.Default);

    - James
    --
    James Moore
    Red Gate Software Ltd
    James Moore
    Head of DBA Tools
    Red Gate Software Ltd
  • Thanks for the help, but it didn't work. It's acting like it is not accepting the setting... Do I need to set these options earlier in the process?

    Has anyone else been able to get this to work?
  • Hi there
    You may want to also configure the comparision session too. Here is a code snippit. (This code snippit also configures the SQL provider aswell.)
    ..... some stuff....
    			mappings.CreateMappings(db1.Tables, db2.Tables);
        
    			mappings.Options = new EngineDataCompareOptions( 
    				MappingOptions.Default, 
    				ComparisonOptions.TrimTrailingSpaces | ComparisonOptions.Default, 
    				SqlOptions.Default); 
    
    			using (ComparisonSession session=new ComparisonSession())
    			{
    				session.Options = mappings.Options;
    				session.CompareDatabases(db1, db2, mappings);
    
    				m_TableDifferences = session.TableDifferences;
        
    				// now get the ExecutionBlock containing the SQL
    				// we want to run this on WidgetLive so we pass on true as the second parameter
    				SqlProvider provider=new SqlProvider();            
    				provider.Options = session.Options;
    
    Hope this helps.
    David
  • That did the trick!

    Thanks!
This discussion has been closed.