Trent L. Taylor (10/13/2008)
Yeah, the DDT actually uses the DatabaseMigrator class itself.That's what I figured...
But if you get stuck, let me know and I will try and give you some code to move ahead.
I'm stuck. I'm creating an array. I step in and see that NameOnServer is definitely set to BayerAcquireLocalTest (which is what I want it to create) but it just keeps ignoring this and goes against BayerAcquireLocal every time no matter what.
I created a small test project with a brand new DDT package and database, tried the same type of code and it works fine, so unfortunately can't send you a simple re-producible scenario. Also, like I said, the deployment wizard works fine with my package, too, and if I change the target name it does what I expect.
I can't figure out what in my code would be causing it to completely ignore the fact that I am changing the NameOnServer property.
Code based on deployment progress dialog sample - is there something wrong with the order I'm doing things?:
Private Sub StartDeployment()
Dim loDatabase As New DatabaseTargetName("BayerAcquireLocalDB")
loDatabase.NameOnServer = CStr(IIf(BayerAcquire.AppMain._TestEnv, "BayerAcquireLocalTest", "BayerAcquireLocal"))
'-- Establish Locals
Dim loSQL As New MicroFour.StrataFrame.DBEngine.SQL.SQLServerSchema()
' Check for database updates - can only update local DB
If My.Computer.FileSystem.FileExists(_PackagePath & "BayerAcquireLocalDB.pkg") Then
Dim connString As String = MicroFour.StrataFrame.Data.DataBasics.DataSources.Item("LocalTables").ConnectionString().ToString()
Dim s As String() = Split(connString, ";")
_SQLServer = s(0).Replace("Data Source=", "")
' _SQLServer = "localhost\SQLEXPRESS"
Else
MsgBox("Database update package not found.", MsgBoxStyle.Exclamation, "Database Update")
DialogResult = Windows.Forms.DialogResult.Cancel
Exit Sub
End If
'-- See if the SQL connection can be established. Change the privates above to make this
' work in your environment if localhost is not a valid connection. Another option is to
' create a form that asks for this information or pull it from the registry.
If Not loSQL.IsValidConnection(_SQLServer, _SQLUserName, _SQLPassword) Then
MsgBox("The specified SQL connection information could not be authenticated. Deployment halted.", MsgBoxStyle.Exclamation, "Invalid Connection")
DialogResult = Windows.Forms.DialogResult.Cancel
Exit Sub
End If
'-- The package path is installed with StrataFrame and resides in the Common Files folder
' _PackagePath = AddBS(Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles)) & "MicroFour\StrataFrame\"
'-- Create the DatabaseMigrator instance
If _SQLUserName.Length = 0 Then
_DatabaseSetup = New DatabaseMigrator(_SQLServer, True, Me)
Else
_DatabaseSetup = New DatabaseMigrator(_SQLServer, False, Me, _SQLUserName, _SQLPassword)
End If
'-- Begin the deployment of the meta-data (does not include the data in this phase)
_DatabaseSetup.EnableLogging = True
_DatabaseSetup.DeployMetaData(_PackagePath & "BayerAcquireLocalDB.pkg", _
"", New DatabaseTargetName() {loDatabase})
End Sub
See attached image showing that when I step on the DeployMetaData you see my NameOnServer is definitely different but it doesn't have any effect. Hmmmm... Maybe I need to try stepping into Strataframe code now that I know how to do this! But let me know if you see anything funny about my code. The only special stuff is that I validate the connection to the server and extract the actual server instance name from the existing connection, but I can't see how that could mess up what's in the databasemigrator.