Options

Register database from script folder

rickybibirickybibi Posts: 25 Bronze 2
edited July 5, 2007 6:10AM in SQL Compare Previous Versions
How to register a database from the script folder creates with "writetoFolder" ?

Comments

  • Options
    Michelle TMichelle T Posts: 566 Gold 1
    If you've just created it with writeToFolder then you should be able to use the following:

    db.Register(path, null, options);

    where 'db' is a fresh Database object, path is a string which contains the path to the folder, and options is an Options with whatever option set you want to use for registration.

    The 'null' is where you would put a ReadFromScriptDatabaseInformation object if you didn't have a SqlCompareDatabaseInfo.xml file in the directory, but as you've just written it out you ought to have one already there with settings in. (If you want to set things like the database version yourself, or there isn't an xml file in the directory, pass in a ReadFromScriptDatabaseInformation object - you can just construct them with the empty constructor and then set the fields manually.)
    Software Developer
    Redgate Software
  • Options
    rickybibirickybibi Posts: 25 Bronze 2
    well ,
    i receive a error.
    I want to comparing a Scriptfolder and a Live Database.

    Help :
    Take the resulting Differences object, create a Work object, and call BuildFromDifferences with a WriteToFileOptions object.

    Error
    The differences parameter refers to a live database, but this API call is for scritps folder synchronizations.
    Parameter name: differences

                RedGate.SQLCompare.Engine.ReadFromFolder.WriteToFileOptions MyWriteToFileOptions = new RedGate.SQLCompare.Engine.ReadFromFolder.WriteToFileOptions();
    
    
    db1.Register(Path, null, Options.Default);
    
    db2.Register(new RedGate.SQLCompare.Engine.ConnectionProperties(ServeurName, databaseName), Options.Default);
    
    
    RedGate.SQLCompare.Engine.Differences MyDifferences = db1.CompareWith(db2, Options.Default);
    
    RedGate.SQLCompare.Engine.Work work = new RedGate.SQLCompare.Engine.Work();
    
    work.BuildFromDifferences(MyDifferences, Options.Default, true, MyWriteToFileOptions);
    
    
  • Options
    Michelle TMichelle T Posts: 566 Gold 1
    I can see your problem:

    Your target database is the live database.

    If your target database is a live database, you should not attempt to pass a WriteToFileOptions object to work.BuildFromDifferences, whatever kind of database your source database is.

    So:

    work.BuildFromDifferences(MyDifferences, Options.Default, true, MyWriteToFileOptions);

    should be:

    work.BuildFromDifferences(MyDifferences, Options.Default, true);

    Hope that helps.
    Software Developer
    Redgate Software
  • Options
    rickybibirickybibi Posts: 25 Bronze 2
    Another question.

    Is't possible to define a different extension for each type script.
    Example : .TAB for tables and .VIW for views ..

    thanks
  • Options
    Michelle TMichelle T Posts: 566 Gold 1
    Sorry, it is not currently possible to define custom file endings for scripts. We've had a couple of requests for this feature and we'll consider implementing it in future, but as SQL Compare currently uses the file endings to determine which files in a folder to read and which to ignore, this is actually more difficult than it looks.
    Software Developer
    Redgate Software
Sign In or Register to comment.