Error Syncronizing Database

krock23krock23 Posts: 6
edited August 17, 2005 9:08AM in SQL Toolkit Previous Versions
Hi, I originally posted this in the SQL Compare forum, it actually occurred when I was using the toolkit.

I am trying to syncronize 2 databases using a snapshot from one database and comparing against another. The compare works fine but I'm failing on the ExecuteBlock statement with an error:

An unhandled exception of type 'System.ArgumentException' occurred in microsoft.visualbasic.dll

Additional information: Argument 'Prompt' cannot be converted to type 'String'.

I am using .net Framework 1.1 and SQL Server 2000

Here is my code:

Sub SynchronizeDatabases()

Dim db1 As Database = New Database()
Dim db2 As Database = New Database()


db1.Register(New ConnectionProperties("KROCK-LAPTOP\RESOURCETRACKING", "RT1", "x", "x"), Options.Default)
db2.LoadFromDisk("c:\RT1Production.snp")

Dim differences As Differences = db1.CompareWith(db2, Options.Default)

Dim difference As Difference

For Each difference In differences
difference.Selected = True
Next

Dim work As Work = New Work()


work.BuildFromDifferences(differences, Options.Default, True)


Console.WriteLine("Messages:")

Dim message As Message

For Each message In work.Messages
Console.WriteLine(message.Text)
Next

Console.WriteLine("Warnings:")

For Each message In work.Warnings
Console.WriteLine(message.Text)
Next



Dim block As ExecutionBlock = work.ExecutionBlock

Console.WriteLine("SQL to synchronize:")

Console.WriteLine(block.ToString())

'run the SQL
Try
Dim utils As Utils = New Utils

utils.ExecuteBlock(block, "KROCK-LAPTOP\RESOURCETRACKING", "RT1", false, "x", "x")
Catch sqlexc As SqlClient.SqlException
MsgBox(sqlexc)
Catch exc As Exception
MsgBox(exc)
Finally
db1.Dispose()
db2.Dispose()
block.Dispose()
End Try

End Sub

Any input would be greatly appreciated.

Ken Roxbury
IS Systems Inc, NY

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hello Ken,

    I don't think that this is actually being caused by the posted code. Maybe it's somewhere in the project properties or somewhere else in your code? Somewhere, this program is being given a command-line argument and this argument is not being accepted for some reason.
  • As far as I can see there is no other code running. The project I am using is SQLCompareCodeSnipits which was installed in the VB folder. Except for the SynchronizeDatabases() method everything else is commented out.
  • I got this to work. I changed the Options on the CompareWith method from using the default to only using the options that I use when I run The SQLCompare application to comapre 2 databases. When I did this it work fine.

    FYI, the options I set were:
    db1.CompareWith(db2, Options.IgnoreFillFactor Or Options.IgnoreWhiteSpace Or Options.IncludeDependencies Or Options.IgnoreFileGroups)

    Ken
This discussion has been closed.