PC Review


Reply
Thread Tools Rate Thread

Deleting database at runtime

 
 
=?Utf-8?B?TXVraWxhbi5Qcy4=?=
Guest
Posts: n/a
 
      21st Jul 2005
I'm using ASP.Net and code behind 'vb'.SQL Server as backend. I want to
delete database at run time. If im deleting the databse using 'DROP DATABASE
databasename' its throwing exception ' Database currently in use'. How to
delete the databse during runtime. I have created a new command and
connection object for deleting the database.And i establish the connection
string to Master database before deleting the database. Please give me some
suggestion.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN
Guest
Posts: n/a
 
      21st Jul 2005
Open a connection to the master database, not the database in question. Run
the following:

select spid from master..sysprocesses where dbid=db_id('DatabaseNameToDrop')

This will give you a list of process connected to the database. You then
have to run a kill command on each process. Rerun to make sure nobody is
connecting. You can now detatch, drop, etc. the database.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************


"Mukilan.Ps." wrote:

> I'm using ASP.Net and code behind 'vb'.SQL Server as backend. I want to
> delete database at run time. If im deleting the databse using 'DROP DATABASE
> databasename' its throwing exception ' Database currently in use'. How to
> delete the databse during runtime. I have created a new command and
> connection object for deleting the database.And i establish the connection
> string to Master database before deleting the database. Please give me some
> suggestion.
>
>

 
Reply With Quote
 
=?Utf-8?B?TXVraWxhbi5Qcy4=?=
Guest
Posts: n/a
 
      22nd Jul 2005
thank you very much, i will try your suggestion. If it works fine then i will
inform you.

"Cowboy (Gregory A. Beamer) - MVP" wrote:

> Open a connection to the master database, not the database in question. Run
> the following:
>
> select spid from master..sysprocesses where dbid=db_id('DatabaseNameToDrop')
>
> This will give you a list of process connected to the database. You then
> have to run a kill command on each process. Rerun to make sure nobody is
> connecting. You can now detatch, drop, etc. the database.
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> ***************************
> Think Outside the Box!
> ***************************
>
>
> "Mukilan.Ps." wrote:
>
> > I'm using ASP.Net and code behind 'vb'.SQL Server as backend. I want to
> > delete database at run time. If im deleting the databse using 'DROP DATABASE
> > databasename' its throwing exception ' Database currently in use'. How to
> > delete the databse during runtime. I have created a new command and
> > connection object for deleting the database.And i establish the connection
> > string to Master database before deleting the database. Please give me some
> > suggestion.
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
runtime (c++) errors when deleting email / folders foxymomma@gmail.com Microsoft Outlook Discussion 3 2nd Sep 2006 03:12 PM
error runtime 9: deleting a worksheet mibispam@gmx.de Microsoft Excel Programming 4 7th Apr 2005 04:42 PM
Deleting a textbox control at runtime Grant Williams Microsoft Excel Programming 6 14th Jun 2004 08:33 AM
Runtime error when deleting a message Microsoft Outlook 0 7th May 2004 10:02 PM
Re: deleting worksheets at runtime J.E. McGimpsey Microsoft Excel Worksheet Functions 0 2nd Sep 2003 06:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:09 PM.