DDT NameOnServer not working


Author
Message
Randy Jean
Randy Jean
StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)
Group: StrataFrame Users
Posts: 105, Visits: 641
I'm so close to having my deployment issues resolved I can taste it, however,I have one nagging problem that I can't seem to figure out. I need to be able to maintain 2 separate SQLExpress local databases, test and live. I have separate locations set for the connection.dat files, etc. The only thing I can't seemt to get to work is creating a database with a different name than what is in my DDT profile. I step in and see that indeed NameOnServer property is getting set to "MyLocalDBTest" but it just keeps updating updating MyLocalDB and never creates the test database. Any ideas?







Dim _DatabaseSetup as New SQL.DatabaseMigrator



Dim loDatabase As New DatabaseTargetName("MyLocalDb")



loDatabase.NameOnServer = CStr(IIf(MyApp.AppMain._TestEnv, "MyLocalDbTest", "MyLocalDb"))



' using NT auth, no user/password

_DatabaseSetup = New DatabaseMigrator("MyServer", True, Me)



_DatabaseSetup.EnableLogging = True

_DatabaseSetup.DeployMetaData("MyLocalDBPackage.pkg", "", New DatabaseTargetName() {loDatabase})




Dustin Taylor
Dustin Taylor
StrataFrame Team Member (664 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
You are setting the "Database name on server" to a different name on the last page of the deployment wizard, correct?

If so, it may be trying to deploy both database to the same .mdf file name. You need to set your file groups to use a replacement value. Edit the primary file group of the database in your DDT profile and change the name to use the $DbName$ replacement value, then try deploying the databases again.


Randy Jean
Randy Jean
StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)
Group: StrataFrame Users
Posts: 105, Visits: 641
I didn't think to even try the deployment wizard to see if that works. This is all in code right now, but that's a good thought.



I did try setting the filename to $dbname$ but then when I tried running my code again it got an error saying: Drop failed for DataFile 'MyLocalDb_Data'. Why would it now be trying to drop something? I checked and there was nothing in they object history of the DDT project so I'm not sure what's going on. I don't want it trying to drop anything, just create a different target database.



Trying to figure this out and also wrestling with Windows Installer trying to figure out how to deploy minor updates without having to add/remove previous version. Why is deployment so complicated? Seems I spend more time on deployment these days than actual coding.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Why would it now be trying to drop something?

It is because the file group name that is being produced is not the same as what exists on disk.  So if you are upgrading existing installs, you will want to take this into your thought process.

Why is deployment so complicated?

Dude...I totally get you here!!! w00t  I have been in this vortex more than once!!!!!

Randy Jean
Randy Jean
StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)
Group: StrataFrame Users
Posts: 105, Visits: 641
Can I concatenate "_Data" after $DbName$? I think that would help me preserve the existing file name.



By the way, ddt deployment wizard is working, lets me change target db and it creates it no problem. My code still doesn't work for some reason. NameOnServer has no effect for some reason. Driving me crazy.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Yup, that is exactly what we do!  Go for it!
Randy Jean
Randy Jean
StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)
Group: StrataFrame Users
Posts: 105, Visits: 641
Cool, that worked as far as fixing it from trying to drop my existing database file, however, still can't get the databasemigrator in my code to create a new database by changing the NameOnServer property. Doesn't make any sense because the ddt deploy wizard seems to work fine and I assume its using the same databasemigrator assembly. Seems like this kind of thing always happens late on a Friday... sigh.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Yeah, the DDT actually uses the DatabaseMigrator class itself.

When you deploy the meta-data, you can supply an array of the the database names in the profile and the names to which they should be deployed.  You might look at the DatabaseMigrator sample (I can't remember off the top of my head if this shows this or not...I am not in the office today otherwise I would look).  But if you get stuck, let me know and I will try and give you some code to move ahead.

Randy Jean
Randy Jean
StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)
Group: StrataFrame Users
Posts: 105, Visits: 641
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.

Attachments
ddt metadata deploy debug.jpg (243 views, 32.00 KB)
Randy Jean
Randy Jean
StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)StrataFrame User (171 reputation)
Group: StrataFrame Users
Posts: 105, Visits: 641
Got it! Man that being able to debug into SF source is the bomb! Turns out it had nothing to do with the NameOnServer property but rather the NameInProfile. Apparently this is case sensitive. If it doesn't find it, however, it doesn't assign the NameOnServer.



In createdatabasenamesdictionary method:







'-- Cycle through the database target names and modify the collection

If DatabaseTargetNames IsNot Nothing Then

For Each loName As DatabaseTargetName In DatabaseTargetNames

If Me._DatabaseNames.ContainsKey(loName.NameInProfile) Then

Me._DatabaseNames(loName.NameInProfile) = loName.NameOnServer

End If

Next

End If







The ContainsKey method is case sensitive so it never assigned NameOnServer.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search