Red Gate forums :: View topic - Version problems
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Toolkit Previous Versions
SQL Toolkit Previous Versions forum

Version problems

Search in SQL Toolkit Previous Versions forum
Post new topic   Reply to topic
Jump to:  
Author Message
pagman



Joined: 21 Jan 2008
Posts: 5

PostPosted: Mon Jan 21, 2008 9:33 am    Post subject: Version problems Reply with quote

I have made schema and data compare buildtask to include in our build on Team Foundation Server.

We cannot get the schema- and data-compare running in the same build-run because the Assembly's versions for datacompare and compare are not the same.

Is it possible to get a version compatible SQL Toolkit or are there any tricks available to get the compare and datacompare running the same process?
Back to top
View user's profile Send private message
richardjm



Joined: 20 May 2005
Posts: 384
Location: Red Gate Software Ltd

PostPosted: Mon Jan 21, 2008 10:19 am    Post subject: Reply with quote

You have to use all of the assemblies from the same directory. If you're using both SQL Compare and SQL Data Compare use the dlls from the SQL Data Compare directory only.

HTH
_________________
Richard Mitchell
Project Manager
Red Gate Software Ltd
Back to top
View user's profile Send private message Send e-mail
pagman



Joined: 21 Jan 2008
Posts: 5

PostPosted: Mon Jan 21, 2008 11:35 am    Post subject: Reply with quote

When using the assemblies from the data compare folder I get the following error when I try a SQL Data compare after a schema compare

System.ArgumentException: TableMappings.Join must called with ViewTableSuperClass arguments.
RedGate.SQLDataCompare.Engine.TableMappings.Join(IDatabaseObject obj1, IDatabaseObject obj2)
RedGate.SQLDataCompare.Engine.TableMappings.Join(ViewTableSuperClass viewtable1, ViewTableSuperClass viewtable2)
Cob.Sfx.Build.Tasks.CompareDataTask.Execute()
Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound)
Back to top
View user's profile Send private message
richardjm



Joined: 20 May 2005
Posts: 384
Location: Red Gate Software Ltd

PostPosted: Mon Jan 21, 2008 11:44 am    Post subject: Reply with quote

Can you give a fragment of your code as there is something strange going on with the called to TableMappings.Join by the looks of it.
_________________
Richard Mitchell
Project Manager
Red Gate Software Ltd
Back to top
View user's profile Send private message Send e-mail
pagman



Joined: 21 Jan 2008
Posts: 5

PostPosted: Mon Jan 21, 2008 11:48 am    Post subject: Reply with quote

Method Execute has to return false if there are differences. The FQN of the tables are located in an array Tables.


Code:


 public override bool Execute()
        {
            bool hasDifferences = false;

            Log.LogMessage(String.Format("Data compare between {0} and {1}.", DatabaseName1, DatabaseName2));

           
            Database db1 = new Database();
            Database db2 = new Database();

            db1.RegisterForDataCompare(new ConnectionProperties(ServerName1, DatabaseName1));
            db2.RegisterForDataCompare(new ConnectionProperties(ServerName2, DatabaseName2));

            TableMappings mappings = new TableMappings();
            mappings.Options.MappingOptions = MappingOptions.Default & ~MappingOptions.IncludeTimestamps;

            foreach (ITaskItem taskItem in Tables)
            {
                TableMapping mapping = (TableMapping)mappings.Join((ViewTableSuperClass)db1.Tables[taskItem.ItemSpec],
                    (ViewTableSuperClass)db2.Tables[taskItem.ItemSpec]);               
                mappings.Add(mapping);
            }
           
            ComparisonSession session = new ComparisonSession();
            session.CompareDatabases(db1, db2, mappings);

            foreach (TableDifference difference in session.TableDifferences)
            {
                if (HasDifferences(difference))
                {
                    hasDifferences = true;
                }
               
            }
            if (hasDifferences)
            {
                Log.LogError("Differences in data found.");
                return false;
            }
            else
            {
                Log.LogMessage("No differences in data found.");
                return true;
            }
           
        }
        #endregion Public Methods


        private bool HasDifferences(TableDifference tableDifference)
        {
            int differenceCount = 0;

            foreach (Row resultsStoreRow in tableDifference.ResultsStore)
            {
                if (resultsStoreRow.Type != Row.RowType.Same)
                {
                    differenceCount++;   
                }

            }
            if (differenceCount > 0)
            {
                Log.LogWarning("Table {0} has {1} data differences.", tableDifference.Name, differenceCount);
                return true;
            }
            return false;
           
        }

Back to top
View user's profile Send private message
richardjm



Joined: 20 May 2005
Posts: 384
Location: Red Gate Software Ltd

PostPosted: Mon Jan 21, 2008 11:58 am    Post subject: Reply with quote

I think this might happen if both the arguments are null. Perhaps you can put a Debug.Assert to make sure this isn't the case i.e. if the tables in your taskitem aren't in the registered databases.
_________________
Richard Mitchell
Project Manager
Red Gate Software Ltd
Back to top
View user's profile Send private message Send e-mail
pagman



Joined: 21 Jan 2008
Posts: 5

PostPosted: Mon Jan 21, 2008 2:31 pm    Post subject: Reply with quote

The problem was indeed that I did not pass the fully qualified name of the tables.

It works now!

Thanks
Back to top
View user's profile Send private message
richardjm



Joined: 20 May 2005
Posts: 384
Location: Red Gate Software Ltd

PostPosted: Mon Jan 21, 2008 2:47 pm    Post subject: Reply with quote

Brilliant - out of interest what is your application for?
_________________
Richard Mitchell
Project Manager
Red Gate Software Ltd
Back to top
View user's profile Send private message Send e-mail
pagman



Joined: 21 Jan 2008
Posts: 5

PostPosted: Mon Jan 21, 2008 2:53 pm    Post subject: Reply with quote

We build applications for a transport company. Since about a year we are using team foundation server to manage source control, builds, ...

Every build we create two databases, one reference database using VS for database professionals and a database using upgrade scripts.

With SQL Compare we check if the upgrade database is the same as the reference database, if not, the build fails.

Regards
Peter
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group