Deploy with DatabaseMigrator class using Connection String


Author
Message
Derek Price
Derek Price
StrataFrame Novice (89 reputation)StrataFrame Novice (89 reputation)StrataFrame Novice (89 reputation)StrataFrame Novice (89 reputation)StrataFrame Novice (89 reputation)StrataFrame Novice (89 reputation)StrataFrame Novice (89 reputation)StrataFrame Novice (89 reputation)StrataFrame Novice (89 reputation)
Group: Forum Members
Posts: 51, Visits: 376
I created a console application to deploy our package to have it be automated. It's based on your Database Installer Sample. Most of the code is reading in the command line arguments, but this is where I decide to run either by a connection string or explicit settings:



_databaseMigrator = ConnectionString.Length > 0 ?

new DatabaseMigrator(connectionString, this) :

new DatabaseMigrator(SQLServer, winAuth, this, SQLUserName, SQLPassword);



_databaseMigrator.DeployMetaData(PackagePath, FrameworkPassword);




When I run the app with these settings, it works flawlessly:



// This works:

SQLServer = "MyServer";

winAuth = true;

SQLUserName = "";

SQLPassword = "";




When I run it with a connection string (that we use on our main application using StrataFrame), it does not work and fails on dropping the exisiting database. We drop the database in the Pre-Deploy Script.



// This does not work:

connectionString = "Data Source=MyServer;Initial Catalog=MyDatabase;Integrated Security=True";




The error I get back is this:



*** Starting Deployment...

Package Path = P:\PathToPackage\DDT_Packages\MyPackage.pkg

Connection String = Data Source=MyDataSource;Initial Catalog=MyDatabase;Integrated Security=True

Windows Authen. = True

Checking SQL Connection...

SQL Connection is valid

Executing Pre-Deployment Scripts, Executing Pre-Deployment Scripts



*** Error Executing Script, SqlException

Cannot drop database "MyDatabase" because it is currently in use.



Source : .Net SqlClient Data Provider



Stack Trace:

at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)

at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)

at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)

at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName,Boolean async)

at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)

at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()

at MicroFour.StrataFrame.DBEngine.SQL.DatabaseMigrator.ExecuteProfileScripts(DataView scriptsToExecute)

***





*** Error Deploying Meta-Data, ThreadAbortException

Thread was being aborted.



Source : MicroFour StrataFrame DBEngine



Stack Trace:

at MicroFour.StrataFrame.DBEngine.SQL.DatabaseMigrator.ExecuteProfileScripts(DataView scriptsToExecute)

at MicroFour.StrataFrame.DBEngine.SQL.DatabaseMigrator.ExecutePreProfileScripts()

at MicroFour.StrataFrame.DBEngine.SQL.DatabaseMigrator.EnsureDatabases()

at MicroFour.StrataFrame.DBEngine.SQL.DatabaseMigrator.DeployMetaDataThread()



***




It almost seems like the DatabaseMigrator instance is grabbing hold of the database preventing it from being dropped, but only when used with a connection string. What am I missing here? I can zip up the project and send it to you directly if you need the code.



Thanks,

Derek
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Derek Price - 15 Years Ago
Trent L. Taylor - 15 Years Ago
Derek Price - 15 Years Ago
Trent L. Taylor - 15 Years Ago
                     I get this right at the beginning just after calling:
...
Derek Price - 15 Years Ago
                         Can you send me a sample of how you are reproducing this? I have not...
Trent L. Taylor - 15 Years Ago
                             I've emailed the solution and package file.

Thanks,...
Derek Price - 15 Years Ago
                                 Got it...I still have some questions. Why is it that you want to use a...
Trent L. Taylor - 15 Years Ago
                                     We actually don't really need to use the connection string. As I...
Derek Price - 15 Years Ago
                                         [quote]Have you been able to reproduce my connection string issue?...
Trent L. Taylor - 15 Years Ago
                                             I'm glad to see we have similar development teams! :D Thanks for...
Derek Price - 15 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search