Unable to create tables & views programming in .net

theWalttheWalt Posts: 3
edited January 4, 2007 3:04PM in SQL Toolkit Previous Versions
I am programming a console app that will compare two dbs. Then
I want to update the second db to match the schema of the first db.
I need to be able to create tables and views if they do not already exist in the second db.

Here is some of the code :

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

Work w = new Work();
w.BuildFromDifferences(differences,Options.None,true);

// everything works fine up to here
Utils u = new Utils();
try
{
u.ExecuteBlock( w.ExecutionBlock, "c","secondDB",true, myUserName, myPassword);
// This steep fails because the tables and views do not already exist in the
// second database
}

Comments

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

    SQL Toolkit will create objects by default if they do not exist in the target database. Have you tried comparing your code to the code in the examples (c:\program files\red gate\sql bundle 5\toolkit sample files)? It's usually best if you're just starting out to make a copy of the example code file that best matches what you want to accomplish, then modify that to make it behave in exactly the right way.
  • Got it working.

    Thanks
Sign In or Register to comment.