-
Locked DB Process when detaching a database in ASP.NET
Greetings,
I am in need of some assistance in programmatically detecting and closing a
database lock process before I execute the sp_detach_db sproc in my ASP.Net
page.
I have looked around and found no info.
If you run detach database from SQL 2000 Manager, and the database in
question is in use, a dialog is displayed with the number of connections and
a button to 'clear' these connections before detaching the database.
In my database management section of my ASP.Net appliaction, when I detach a
database, I need to beable to close any locked process before detaching the
database.
Any articles, information or brainstorming would be great.
Some brainstorming I have done is..
- search SQL Server for any locks with the database name
- get the process number
- kill the process
Sounds easy, but I am also wondering if there are any built in .NET methods
or classes that may ease my development.
Thanx
Micah Nasarow
-
Re: Locked DB Process when detaching a database in ASP.NET
you can use the sql server command
alter database <database name >
set SINGLE_USER WITH ROLLBACK IMMEDIATE
go
this will drop all other connections other than your own and you can then
detach the database.
"Micah Nasarow" <micahn@opus-i.com> wrote in message
news:3c4a1f8c@147.208.176.211...
> Greetings,
>
> I am in need of some assistance in programmatically detecting and closing
a
> database lock process before I execute the sp_detach_db sproc in my
ASP.Net
> page.
>
> I have looked around and found no info.
>
> If you run detach database from SQL 2000 Manager, and the database in
> question is in use, a dialog is displayed with the number of connections
and
> a button to 'clear' these connections before detaching the database.
>
> In my database management section of my ASP.Net appliaction, when I detach
a
> database, I need to beable to close any locked process before detaching
the
> database.
>
> Any articles, information or brainstorming would be great.
>
> Some brainstorming I have done is..
> - search SQL Server for any locks with the database name
> - get the process number
> - kill the process
>
> Sounds easy, but I am also wondering if there are any built in .NET
methods
> or classes that may ease my development.
>
> Thanx
>
> Micah Nasarow
>
>
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks