|
-
Jul 29th, 2004, 09:36 AM
#1
Thread Starter
Frenzied Member
Cannot drop SQL Server database
I have an ASP.NET page that connects to a SQL Server 2000 database. I want to delete the database and I get this error:
Error 3702: Cannot drop the database 'db' because it is currently in use.
I have made sure to call .Close() on all my connections and .Dispose() on all the database objects. The only way I can delete the database is to go to Task Manager and End Task on aspnet_wp.exe
It worries me the database is locked even after I close the page and the development environment.
-
Jul 29th, 2004, 01:07 PM
#2
I wonder how many charact
Well, we are able to drop our database without ending the aspnet_wp process... so perhaps you are leaking a connection somewhere.
-
Jul 29th, 2004, 03:56 PM
#3
Thread Starter
Frenzied Member
I've called
con.Close(); con.Dispose(); con = null;
on every connection. Am I missing something?
This is weird.
-
Jul 29th, 2004, 06:49 PM
#4
Do you have access to 'Sql Query analyser'? If so you could try running 'sp_who' procedure to check if any users/processes are connected to the database at the time.
Don't know if that helps.......
-
Jul 30th, 2004, 09:02 AM
#5
Thread Starter
Frenzied Member
Good idea.
I ran EXEC sp_who from query analyzer after I open and close the page and get this:
Code:
spid ecid status login hostname blk dbname cmd
1 0 background sa 0 NULL LAZY WRITER
2 0 sleeping sa 0 NULL LOG WRITER
3 0 background sa 0 master SIGNAL HANDLER
4 0 background sa 0 NULL LOCK MONITOR
5 0 background sa 0 master TASK MANAGER
6 0 background sa 0 master TASK MANAGER
7 0 sleeping sa 0 NULL CHECKPOINT SLEEP
8 0 background sa 0 master TASK MANAGER
9 0 background sa 0 master TASK MANAGER
10 0 background sa 0 master TASK MANAGER
11 0 background sa 0 master TASK MANAGER
51 0 runnable domain\userName worstationID 0 master SELECT
52 0 sleeping domain\userName worstationID 0 master AWAITING COMMAND
53 0 sleeping domain\userName worstationID 0 dbToDelete AWAITING COMMAND
I can wait like 5 or so minutes, run the same proc. from Q.A. and the last line with my database name is gone.
-
Jul 30th, 2004, 09:31 AM
#6
Thread Starter
Frenzied Member
If I run this code and check sp_who, the database doesn't stay open:
Code:
string strCon = "server=;database=;trusted_connection=true;";
SqlConnection sqlCon = new SqlConnection(strCon);
SqlDataAdapter sqlDat = new SqlDataAdapter("SELECT * FROM Table1;", sqlCon);
sqlCon.Close();
but as soon as I fill a DataTable, that's what does it.
Code:
string strCon = "server=;database=;trusted_connection=true;";
SqlConnection sqlCon = new SqlConnection(strCon);
SqlDataAdapter sqlDat = new SqlDataAdapter("SELECT * FROM Table1;", sqlCon);
DataTable dt = new DataTable();
sqlDat.Fill(dt);
dt.Clear();
sqlCon.Close();
crazy why filling a DataTable would keep the DB open.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|