What am I missing
private void button1_Click(object sender, EventArgs e)
{
Server sv = new Server("ESTACION15"); Database db = sv.Databases["GescomDllo"] ; Database db2 = new Database(sv, "PRUEBA"); // db2.Create(); Transfer xfr;xfr =
new Transfer(db);xfr.CopyAllObjects=
true;xfr.CopyAllTables =
true;xfr.Options.WithDependencies =
true;xfr.Options.ContinueScriptingOnError =
true;xfr.DestinationDatabase =
"PRUEBA";xfr.DestinationServer = sv.Name;
xfr.DestinationLoginSecure =
true;xfr.CopySchema =
true; //'Script the transfer. Alternatively, perform immediate data transfer with TransferData method.xfr.ScriptTransfer();
}

This SMO transfer script doesnt transfer ?
Nasty
It creates the database but nothing else happens.
This is the code
private
void button1_Click(object sender, EventArgs e){
try { Server sv = new Server("ESTACION15"); Database db = sv.Databases["GescomDllo"]; Database db2 = new Database(sv, "PRUEBA");db2.Create();
Transfer xfr;xfr =
new Transfer(db);xfr.DestinationServer =
"ESTACION15";xfr.DestinationLogin =
"gescom";xfr.DestinationPassword =
"gescom";xfr.CopyAllObjects =
true;xfr.Options.WithDependencies =
true;xfr.Options.ContinueScriptingOnError =
false;xfr.DestinationDatabase =
"PRUEBA"; //'Script the transfer. Alternatively, perform immediate data transfer with TransferData method.xfr.ScriptTransfer();
xfr.TransferData();
richTextBox1.Text = xfr.ToString();
}
catch (Exception ex){
richTextBox1.Text = ex.Message;
}
}
Liew Vai Teng
Peter
Drea27
System.Collections.Specialized.
StringCollection script = new StringCollection();script = trans.ScriptTransfer();
foreach (String str in script){
Console.WriteLine("GO"); Console.WriteLine(str);}
Peter
Kripa
Still waiting for help, or is this a bug in sql 2005
Steven Ramacher
The Transfer object has properties that you can set to tell it what to copy, like CopyAllUsers and so on. It also has a ScriptingOptions object called Options that has properties you can set.
xfr.CopyAllUsers = false;
and
xfr.Options.Permissions = false;
Also, make sure the connection you are using has appropriate permissions.
nukthem
FreddieCode
ScriptTransfer() just creates the scripts, it doesn't execute them. You need to call ExecuteNonQuery on the new database object, passing the StringCollection containing the generated scripts as a parameter.
Dim
strColl As StringCollectionstrColl = xsfr.ScriptTransfer()
db.ExecuteNonQuery(strColl)Hiya
I go to management studio after it and there are no tables on the database PRUEBA.
the scripttransfer method takes more than 5 minutes and it seems is not making anything.
Thanks
Hubman
Hi,
I have the exact same problem. My code is pretty much the same, the ScriptTransfer() does create the scripts but the tables are not created on the target servers in the target db. The db is created though; please advise.
Thanks
Nick
Aksi-
I removed
xfr.CopyAllTables =
true; and leftxfr.CopyAllObjects = true;
It still doesnt work
private
void button1_Click(object sender, EventArgs e){
try { Server sv = new Server("ESTACION15"); Database db = sv.Databases["GescomDllo"]; Database db2 = new Database(sv, "PRUEBA"); Transfer xfr;xfr =
new Transfer(db);xfr.DestinationServer =
"ESTACION15";xfr.DestinationLogin =
"gescom";xfr.DestinationPassword =
"gescom";xfr.CopyAllObjects =
true;xfr.Options.WithDependencies =
true;xfr.Options.ContinueScriptingOnError =
false;xfr.DestinationDatabase =
"PRUEBA"; //'Script the transfer. Alternatively, perform immediate data transfer with TransferData method.xfr.ScriptTransfer();
}
catch (Exception ex){
richTextBox1.Text = ex.Message;
}
}
NJC
I have a richtextbox on my application and I want the result of the script to be copied in that richtextbox.
I will try in a few moments , maybe it was a bug of sql ctps or vs 2005 rc. and now I have Rtms
Thanks
rmillerii
Thank you, I appreciate your help. The code still gives error at the ExecuteNonQuery:
"ExecuteNonQuery failed for Database 'TEST'. "
InnerException {"Cannot find the user 'SZ875492', because it does not exist or you do not have permission.\r\nCREATE SCHEMA failed due to previous errors."} System.Exception {System.Data.SqlClient.SqlException}
It is trying to import users which I don't want to. How I ignore users and their permission when generating schema
Thanks
Nick
Derek Moffett
ScriptTransfer
andExecuteNonQuery, I am getting an error " User or Role already exists in the current database ". Please help.
Pansailor_74
"xfr.CopyAllTables = true;" is redundant as you already specify to copy all objects.
You need to create the target database, so ensure "// db2.Create();" is not commented.
If that still fails, try first ScriptTransfer() so that can verify whether a script is actually generated (debug, or print the StringCollection that is output).