|
-
May 3rd, 2005, 03:28 AM
#1
Thread Starter
Hyperactive Member
Not able to drop database after opening datatable
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:
VB 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()
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?
It is easy when you know it.
-
May 3rd, 2005, 04:16 AM
#2
Re: Not able to drop database after opening datatable
try:
VB Code:
vConnection.Close
vConnection.Dispose()
vConnection = Nothing
Think it's the .Close bit that you need.
Woof
-
May 3rd, 2005, 04:35 AM
#3
Thread Starter
Hyperactive Member
Re: Not able to drop database after opening datatable
Thanks Wokawidget. I tried the code you suggested, but that did not work. Still I am not able to drop the database.
It is easy when you know it.
-
May 3rd, 2005, 05:09 AM
#4
Re: Not able to drop database after opening datatable
Hmmm...I know this will make your app not work...but just try:
VB Code:
vDataTable.Dispose
vDataTable = Nothing
add that after you toast the connection object in the above code.
Woka
-
May 3rd, 2005, 05:20 AM
#5
Thread Starter
Hyperactive Member
Re: Not able to drop database after opening datatable
Hmmm...I know this will make your app not work...but just try:
visual basic code:--------------------------------------------------------------------------------
vDataTable.Dispose
vDataTable = Nothing
--------------------------------------------------------------------------------
add that after you toast the connection object in the above code.
I tried this too. Still I am getting the same error message.
It is easy when you know it.
-
May 4th, 2005, 06:17 AM
#6
Member
Re: Not able to drop database after opening datatable
Try this
vConnection.Close
vConnection.Dispose()
vConnection = Nothing
Sleep 2000
-
May 4th, 2005, 03:34 PM
#7
-
May 6th, 2005, 07:41 AM
#8
Thread Starter
Hyperactive Member
Re: Not able to drop database after opening datatable
It is easy when you know it.
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
|