Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Not able to drop database after opening datatable

Author  Topic 

Utpal
Posting Yak Master

179 Posts

Posted - 2005-05-03 : 04:34:24
Hi everybody,

I am using VB Webforms as my front end and MSDE 2000 as my back end. I am not able to drop a database after executing the following vb code on that database:

[CODE]
Dim vConnection As New SqlConnection(vConnectionString)
Dim vAdapter As New SqlDataAdapter("SELECT party_type_code, party_type_name, party_type_imported" & _
" FROM Party_Type" & _
" ORDER BY party_type_name", vConnection)
Dim vDataTable As New DataTable()
vAdapter.Fill(vDataTable)
vAdapter.Dispose()
vConnection.Dispose()
[/CODE]

On trying to drop the database using the SQL Command "DROP DATABASE PPCABCD2005", I get the error message:
Cannot drop the database 'PPCABCD2005' because it is currently in use ...
However, if I don't execute the above code, I am able to drop it. Why is it so? What is the solution to this problem?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-05-03 : 05:05:08
After executing this, you need to close the connection and connect to master database and do drop database PPCABCD2005

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Utpal
Posting Yak Master

179 Posts

Posted - 2005-05-03 : 05:49:44
Thanks madhivanan. I tried closing the connection object using vConnection.Close() and then executing "DROP DATABASE PPCABCD2005" from Master, but that did not work. Still I get the same error message.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-05-03 : 06:31:40
Make sure that no part of your application object has connected to that Database

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -