OK, I have tried just about everything over the past 9 hours. I think I've read through every forum regarding anything similar to errors with SMO and TransferData().
However, I still can't fix my problem.
What I'm trying to accomplish is a workaround for deploying my database application using ClickOnce. Since I can't include the database when upgrading (which would wipe out users' data), I want to have a 'Master Database' that is used as a reference to both initially create, and to selectively update, the main 'User Database'. I'm not sure if that is possible, yet...because SMO is not working for me (I'm sure there are more laborious methods to do what I want, but SMO should work...I can't help but think there is a bug).
Here is my current code:
'Master Database
Dim dbName_Master As String Dim SqlCon_Master As SqlClient.SqlConnection = New SqlClient.SqlConnection(My.Settings.LM_Master_SQLConStr)SqlCon_Master.Open()
dbName_Master = SqlCon_Master.Database.ToString()
Dim SC As New ServerConnection(SqlCon_Master) Dim srv As New Smo.Server(SC) 'Verify User Instance connectionConsole.WriteLine(
"User Instance Server: " & srv.InstanceName.ToString) 'Select the Master Database as the source db Dim dbMaster As Smo.DatabasedbMaster = srv.Databases(dbName_Master)
'Define a Transfer object and set the required options and properties. Dim xfr As Smo.Transferxfr =
New Smo.Transfer(dbMaster)xfr.CopyAllObjects =
Truexfr.CopyAllUsers =
Truexfr.CopyData =
Truexfr.CreateTargetDatabase =
Truexfr.DropDestinationObjectsFirst =
True xfr.DestinationDatabase = "TestDB"xfr.DestinationServer = srv.Name
xfr.DestinationLoginSecure =
Truexfr.CopySchema =
Truexfr.Options.WithDependencies =
Truexfr.Options.ContinueScriptingOnError =
Truexfr.Options.NoIdentities =
Falsexfr.Options.NoCollation =
Truexfr.Options.Indexes =
Truexfr.CopyAllDefaults =
Truexfr.Options.AllowSystemObjects =
Truexfr.Options.DriAll =
Truexfr.Options.XmlIndexes =
True 'Script the transfer. Alternatively perform immediate data transfer with TransferData method. Dim StrColl As New System.Collections.Specialized.StringCollectionStrColl = xfr.ScriptTransfer()
For Each str As String In StrCollConsole.WriteLine(str)
Nextxfr.TransferData()
The final error is:
*****
DtsRuntimeException was unhandled...
Exception from HRESULT: 0xC0011008
*****
I also have not seen any examples or documentation on how to store the new database in a specific location on the hard drive, once the transfer is complete.
In fact, SMO has surprisingly little documentation that I can find (which is why the code above may seem a little redundant when setting the xfr options...). I would really appreciate some help.
Thank you,
AL