Options

Work.ScriptObject not working

rduclosrduclos Posts: 8
edited September 27, 2006 11:05AM in SQL Toolkit Previous Versions
How do i use Work.ScriptObject? I have a database object created with:
Private _DataBase as New RedGate.SQLCompare.Engine.Database

When i try to use ScriptObject on my work object it fails because _Database does not implement IDatabaseObject. What do i do to use ScriptObject?

Code Sample:
Private _Database As RedGate.SQLCompare.Engine.Database

Sub Main()
_Database = New RedGate.SQLCompare.Engine.Database
_Database.Register(New RedGate.SQLCompare.Engine.ConnectionProperties("Server", "Database", "UserID", "Password"), RedGate.SQLCompare.Engine.Options.Default)

Dim oWork As New RedGate.SQLCompare.Engine.Work
Dim regions As RedGate.SQLCompare.Engine.Regions
regions = oWork.ScriptObject(_Database, RedGate.SQLCompare.Engine.Options.Default)

For Each reg As RedGate.SQLCompare.Engine.Region In regions
Console.WriteLine("{0} {1}{2}{3}", reg.Name, reg.GetType.ToString(), Environment.NewLine, reg.SQL)
Next
End Sub
Thank you,
Ryan

Comments

  • Options
    Hi Ryan,

    From your source code, it looks a bit like you want to script the whole database, whereas ScriptObject is intended for a single database object, such as a table, view, or stored procedure.

    If you want to script a whole database, you can do this by comparing a registered database object to an empty database object and get an executionblock as in the code samples.
  • Options
    I was trying to script the whole database with ScriptObject because i wanted to see what the region object would allow me to do.
    Thank you,
    Ryan
  • Options
    Hello Ryan,

    You can only do this with individual database objects, I'm afraid...
Sign In or Register to comment.