Error Syncronizing Database
krock23
Posts: 6
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
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
This discussion has been closed.
Comments
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.
FYI, the options I set were:
db1.CompareWith(db2, Options.IgnoreFillFactor Or Options.IgnoreWhiteSpace Or Options.IncludeDependencies Or Options.IgnoreFileGroups)
Ken