Unable to create tables & views programming in .net
theWalt
Posts: 3
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
}
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
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.
Thanks