Hello,
I have been doing some testing. I am filling a Dataset using a DataAdapter.
If I create a new connection to SQL Express without calling the
DataAdapter's Fill Method I can Drop the Database.
If I Fill the Dataset with the DataAdapter, dispose the connection and the
DataAdapter and create a new connection it still wont Drop the Database.
Even if the Dataset is empty it still does not work. It appears that
calling the DataAdapter before dropping the table keeps the database in use
weather it has finished it's job or not.
I can't even call a Stored Procedure to drop the Database if I call the
DataAdapter First. Even if I run the program and call the DataAdapter and
go into SQL Express Management Studio, I still get the same error. Only
when I shut down the program or drop the table without using the DataAdapter
does it work.
Is there a way around this?
Thanks
Chuck
[quoted text, click to view] "Charles A. Lackman" <Charles@CreateItSoftware.net> wrote in message
news:epQ433v9GHA.1172@TK2MSFTNGP03.phx.gbl...
Hello,
I am using SQL Express and Visual Studion 2003. I am trying to DROP
DATABASE Customers using a Stored Procedure and also using ADO.NET.
Query:
IF EXISTS (SELECT name FROM sys.databases WHERE name = Customers) DROP
DATABASE [Customers]
ConnectionString:
RemoveConnectionString = "Server = MyComputer\SQLExpress;UID=sa;
Password=MyPassword;Initial Catalog=master"
Everytime I call the procedure or ExecuteNonQuery I get:
Cannot Drop Database 'Customers' because database is currently in use. by
sqlclient.Data.SqlClient.SqlCommand.ExecuteNonQuery()
I have no problems Dropping the Tables.
Thanks,
Chuck