A
AAaron123
I want to free up a database file in App_Data so that I can backup the
entire solution.
I detached the DB ( think) with the following:
Try
Dim connection As New SqlConnection(ConnectionString)
connection.Open()
Dim command As New SqlCommand("sp_detach_db", connection)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add(New SqlParameter("@dbname", DatabaseName))
command.Parameters.Add(New SqlParameter("@skipchecks", "'false'"))
command.ExecuteNonQuery()
connection.Close()
Catch ex As SqlException
Throw New ApplicationException("Detach database failed: " + ex.ToString())
End Try
Which I debug step through and it does not through the exception.
But when I try to copy the solution I get the message that the file is being
used by another person or program.
I removed the connection string in my program that would enable my program
to open that DB and then ran the program and detached the DB but still got
the error message.
I waited 20 minutes to let the sessions die and still got the message.
I open the SQL Server 2008 Management Studio and see that the DB is still
listed.
Does that mean it is not detached?
If it were detached it would not be listed - correct?
So it appears something is wrong with my detach code (probably).
Can you suggest something I could try?
Thanks
entire solution.
I detached the DB ( think) with the following:
Try
Dim connection As New SqlConnection(ConnectionString)
connection.Open()
Dim command As New SqlCommand("sp_detach_db", connection)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add(New SqlParameter("@dbname", DatabaseName))
command.Parameters.Add(New SqlParameter("@skipchecks", "'false'"))
command.ExecuteNonQuery()
connection.Close()
Catch ex As SqlException
Throw New ApplicationException("Detach database failed: " + ex.ToString())
End Try
Which I debug step through and it does not through the exception.
But when I try to copy the solution I get the message that the file is being
used by another person or program.
I removed the connection string in my program that would enable my program
to open that DB and then ran the program and detached the DB but still got
the error message.
I waited 20 minutes to let the sessions die and still got the message.
I open the SQL Server 2008 Management Studio and see that the DB is still
listed.
Does that mean it is not detached?
If it were detached it would not be listed - correct?
So it appears something is wrong with my detach code (probably).
Can you suggest something I could try?
Thanks