Red Gate forums :: View topic - Problem with data compare api: ResultsStore is empty
Return to www.red-gate.com RSS Feed Available

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

Problem with data compare api: ResultsStore is empty

Search in SQL Comparison SDK Previous Versions forum
Post new topic   Reply to topic
Jump to:  
Author Message
Christian M. Müller



Joined: 28 Sep 2010
Posts: 3

PostPosted: Wed Oct 06, 2010 2:52 pm    Post subject: Problem with data compare api: ResultsStore is empty Reply with quote

Hi there

I have a problem with the data compare api (version 8.1.1).

My source database is a scripts folder, my target database is a sql server 2008 database.

Here the code:

Code:

        Dim dbSourceFaktura As New Database
        Dim dbTargetFaktura As New Database

        Dim sqlProv As New SqlProvider

        dbSourceFaktura.Status = New StatusEventHandler(AddressOf StatusCallbackHandlerSourceFaktura)
        dbTargetFaktura.Status = New StatusEventHandler(AddressOf StatusCallbackHandlerTargetFaktura)

        Dim sdiFaktura As New ScriptDatabaseInformation
        sdiFaktura.SQLServerDBVersion = RedGate.Shared.SQL.Server.SQLVersion.SqlServer2008
        dbSourceFaktura.RegisterForDataCompare(Path.Combine(AppGlobals.Settings.TempWorkPath, "scriptsfolder\faktura"), sdiFaktura, Options.Default)
        dbTargetFaktura.RegisterForDataCompare(New ConnectionProperties(m_Server, m_DbFaktura, m_User, m_Pass), Options.Default)



        Dim mappings As New TableMappings
        mappings.Options = New EngineDataCompareOptions(MappingOptions.Default, ComparisonOptions.Default, SqlOptions.Default)

        Dim parameterMapping As TableMapping = mappings.Join(dbSourceFaktura.Tables("[dbo].[Parameter]"), dbTargetFaktura.Tables("[dbo].[Parameter]"))

        parameterMapping.FieldMappings.Clear()
        parameterMapping.FieldMappings.Add(New FieldMapping(parameterMapping.Obj1.Fields("PAR_Key"), parameterMapping.Obj2.Fields("PAR_Key"), FieldMappingStatus.Success))
        parameterMapping.FieldMappings.Add(New FieldMapping(parameterMapping.Obj1.Fields("PAR_KeyVorgaenger"), parameterMapping.Obj2.Fields("PAR_KeyVorgaenger"), FieldMappingStatus.Success))
        parameterMapping.FieldMappings.Add(New FieldMapping(parameterMapping.Obj1.Fields("PAR_Bezeichnung"), parameterMapping.Obj2.Fields("PAR_Bezeichnung"), FieldMappingStatus.Success))
        parameterMapping.FieldMappings.Add(New FieldMapping(parameterMapping.Obj1.Fields("PAR_Beschreibung"), parameterMapping.Obj2.Fields("PAR_Beschreibung"), FieldMappingStatus.Success))
        parameterMapping.FieldMappings.Add(New FieldMapping(parameterMapping.Obj1.Fields("PAR_Datentyp"), parameterMapping.Obj2.Fields("PAR_Datentyp"), FieldMappingStatus.Success))
        parameterMapping.FieldMappings.Add(New FieldMapping(parameterMapping.Obj1.Fields("PAR_Standardwert"), parameterMapping.Obj2.Fields("PAR_Standardwert"), FieldMappingStatus.Success))
        parameterMapping.FieldMappings.Add(New FieldMapping(parameterMapping.Obj1.Fields("PAR_KzSystem"), parameterMapping.Obj2.Fields("PAR_KzSystem"), FieldMappingStatus.Success))

        parameterMapping.MatchingMappings.Clear()
        parameterMapping.MatchingMappings.Add(New FieldMapping(parameterMapping.Obj1.Fields("PAR_Key"), parameterMapping.Obj2.Fields("PAR_Key"), FieldMappingStatus.Success))

        parameterMapping.RefreshMappingStatus()

        mappings.Add(parameterMapping)

        Dim sessionFaktura As New RedGate.SQLDataCompare.Engine.ComparisonSession
        sessionFaktura.Status = New StatusEventHandler(AddressOf StatusCallbackHandlerSession)
        sessionFaktura.Options = mappings.Options
        sessionFaktura.CompareDatabases(dbSourceFaktura, dbTargetFaktura, mappings, SessionSettings.Default)


        Dim eb As ExecutionBlock = sqlProv.GetMigrationSQL(sessionFaktura, True)

        Debug.WriteLine(eb.GetString)

        eb.Dispose()

        sessionFaktura.Dispose()

        dbSourceFaktura.Dispose()
        dbTargetFaktura.Dispose()




The Problem is, that the generated sql script does not have any insert or update statements. But i expect about 100 insert statements.
I also tried to use the SchemaMappings object from the examples. With the same result.

The generated sql script looks like this:
Code:

/*
Run this script on:

C:\Users\mueller.MITTELSTANDSBUE\AppData\Local\Temp\3987\scriptsfolder\faktura – this database will be modified

to synchronize its data with:

THEODEN.b4y_faktura – this scripts folder will not be modified

You are recommended to back up your database before running this script

Script created by SQL Data Compare version 8.1.1 from Red Gate Software Ltd at 06.10.2010 15:26:11

*/
      
SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS, NOCOUNT ON
GO
SET DATEFORMAT YMD
GO
SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
-- Pointer used for text / image updates. This might not be needed, but is declared here just in case
DECLARE @pv binary(16)

-- Drop constraints from [dbo].[Parameter]
ALTER TABLE [dbo].[Parameter] DROP CONSTRAINT [FK_Parameter_Parameter]

-- Add constraints to [dbo].[Parameter]
ALTER TABLE [dbo].[Parameter] ADD CONSTRAINT [FK_Parameter_Parameter] FOREIGN KEY ([PAR_KeyVorgaenger]) REFERENCES [dbo].[Parameter] ([PAR_Key])
COMMIT TRANSACTION
GO


And by the way... i guess there is a little bug in the sql script. The source and target databases are wrong.

There must be something wrong im my code.
If i use SQL Data Compare UI (Professional) with exact the same scripts folder and target database to create the sql script its absolutely correct.

I hope somebody can help me!

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



Joined: 07 Oct 2010
Posts: 1

PostPosted: Thu Oct 07, 2010 9:51 am    Post subject: Reply with quote

I've got exactly the same problem here.
I'd need help ASAP Sad

Thx in advance Embarassed
Back to top
View user's profile Send private message
Christian M. Müller



Joined: 28 Sep 2010
Posts: 3

PostPosted: Thu Oct 07, 2010 12:41 pm    Post subject: Reply with quote

I just tried to compare the data between two live databases. Its working.
But why not with the scriptsfolder as the sourcedatabase??
Back to top
View user's profile Send private message
Christian M. Müller



Joined: 28 Sep 2010
Posts: 3

PostPosted: Thu Oct 07, 2010 1:52 pm    Post subject: Reply with quote

ITS WORKING Laughing

To compare the data between scripts folder and a live db you must set a new FolderDataSource object.
From this object call the LoadScriptDatabaseInfomation-method to retrive a ScriptDatabaseInformation-object.

Then change the SQLServerDBVersion-property to the right sql server version. In my case its RedGate.Shared.SQL.Server.SQLVersion.SqlServer2008.

Now you can pass the ScriptDatabaseInformation-object into the RegisterForDataCompare-method.

Code:

 Dim sdiFaktura As New ScriptDatabaseInformation
        Dim ds As New ReadFromFolder.FolderDataSource(Path.Combine(AppGlobals.Settings.TempWorkPath, "scriptsfolder\faktura"))
        sdiFaktura = FolderDataSource.LoadScriptDatabaseInfomation(Path.Combine(AppGlobals.Settings.TempWorkPath, "scriptsfolder\faktura"), ds.Errors)
        sdiFaktura.SQLServerDBVersion = RedGate.Shared.SQL.Server.SQLVersion.SqlServer2008


        dbSourceFaktura.RegisterForDataCompare(Path.Combine(AppGlobals.Settings.TempWorkPath, "scriptsfolder\faktura"), sdiFaktura, Options.Default)
        dbTargetFaktura.RegisterForDataCompare(New ConnectionProperties(m_Server, m_DbFaktura, m_User, m_Pass), Options.Default)
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