473,395 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to disconnect all connections of a Database.

ad
I write a restore program to restore a database.
But it must stop all connecions to the database before resotre.
How can I stop all connecions to the database by program?
Nov 20 '05 #1
7 7172
ad,

There is no way to do this out of the box. If anything, it depends on
the database. Most likely, you will have to use some sort of administrative
interface (there might or might not be one you can access programatically,
depending on the database) to kick everyone off.

Which database are you using?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I write a restore program to restore a database.
But it must stop all connecions to the database before resotre.
How can I stop all connecions to the database by program?

Nov 20 '05 #2
If you are using SQL Server...

Take it offline:
http://developer.mimer.com/documenta...tements84.html

Restore it:
http://msdn.microsoft.com/library/de...ra-rz_25rm.asp

--

Derek Davis
dd******@gmail.com

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Ot**************@TK2MSFTNGP15.phx.gbl...
ad,

There is no way to do this out of the box. If anything, it depends on
the database. Most likely, you will have to use some sort of
administrative interface (there might or might not be one you can access
programatically, depending on the database) to kick everyone off.

Which database are you using?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I write a restore program to restore a database.
But it must stop all connecions to the database before resotre.
How can I stop all connecions to the database by program?


Nov 20 '05 #3
A better link for the offline part:

http://msdn.microsoft.com/library/de...da-di_8c32.asp

--

Derek Davis
dd******@gmail.com

"carion1" <dd******@gmail.com> wrote in message
news:e7**************@tk2msftngp13.phx.gbl...
If you are using SQL Server...

Take it offline:
http://developer.mimer.com/documenta...tements84.html

Restore it:
http://msdn.microsoft.com/library/de...ra-rz_25rm.asp

--

Derek Davis
dd******@gmail.com

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:Ot**************@TK2MSFTNGP15.phx.gbl...
ad,

There is no way to do this out of the box. If anything, it depends on
the database. Most likely, you will have to use some sort of
administrative interface (there might or might not be one you can access
programatically, depending on the database) to kick everyone off.

Which database are you using?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I write a restore program to restore a database.
But it must stop all connecions to the database before resotre.
How can I stop all connecions to the database by program?



Nov 20 '05 #4
ad
Thanks,
I use the codes below, but it fail when there are some users accessing the
database

------------------------------------------------------------------------------------------------------------------
C. Take a database offline
This example takes the sales database offline if there are no users
accessing the database.

USE master
EXEC sp_dboption 'sales', 'offline', 'TRUE'

"carion1" <dd******@gmail.com> ¼¶¼g©ó¶l¥ó·s»D:uh****************@TK2MSFTNGP14.phx .gbl...
A better link for the offline part:

http://msdn.microsoft.com/library/de...da-di_8c32.asp

--

Derek Davis
dd******@gmail.com

"carion1" <dd******@gmail.com> wrote in message
news:e7**************@tk2msftngp13.phx.gbl...
If you are using SQL Server...

Take it offline:
http://developer.mimer.com/documenta...tements84.html

Restore it:
http://msdn.microsoft.com/library/de...ra-rz_25rm.asp

--

Derek Davis
dd******@gmail.com

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:Ot**************@TK2MSFTNGP15.phx.gbl...
ad,

There is no way to do this out of the box. If anything, it depends
on the database. Most likely, you will have to use some sort of
administrative interface (there might or might not be one you can access
programatically, depending on the database) to kick everyone off.

Which database are you using?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I write a restore program to restore a database.
But it must stop all connecions to the database before resotre.
How can I stop all connecions to the database by program?



Nov 20 '05 #5
Well you could find who is connected to the db in question with sp_who and
then kill those open connections.

--

Derek Davis
dd******@gmail.com

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:OP**************@TK2MSFTNGP15.phx.gbl...
Thanks,
I use the codes below, but it fail when there are some users accessing the
database

------------------------------------------------------------------------------------------------------------------
C. Take a database offline
This example takes the sales database offline if there are no users
accessing the database.

USE master
EXEC sp_dboption 'sales', 'offline', 'TRUE'

"carion1" <dd******@gmail.com>
¼¶¼g©ó¶l¥ó·s»D:uh****************@TK2MSFTNGP14.phx .gbl...
A better link for the offline part:

http://msdn.microsoft.com/library/de...da-di_8c32.asp

--

Derek Davis
dd******@gmail.com

"carion1" <dd******@gmail.com> wrote in message
news:e7**************@tk2msftngp13.phx.gbl...
If you are using SQL Server...

Take it offline:
http://developer.mimer.com/documenta...tements84.html

Restore it:
http://msdn.microsoft.com/library/de...ra-rz_25rm.asp

--

Derek Davis
dd******@gmail.com

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:Ot**************@TK2MSFTNGP15.phx.gbl...
ad,

There is no way to do this out of the box. If anything, it depends
on the database. Most likely, you will have to use some sort of
administrative interface (there might or might not be one you can
access programatically, depending on the database) to kick everyone
off.

Which database are you using?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
>I write a restore program to restore a database.
> But it must stop all connecions to the database before resotre.
> How can I stop all connecions to the database by program?
>
>



Nov 20 '05 #6
ad
Thanks,
Could you give me an example?
"carion1" <dd******@gmail.com> ¼¶¼g©ó¶l¥ó·s»D:ek**************@TK2MSFTNGP12.phx.g bl...
Well you could find who is connected to the db in question with sp_who and
then kill those open connections.

--

Derek Davis
dd******@gmail.com

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:OP**************@TK2MSFTNGP15.phx.gbl...
Thanks,
I use the codes below, but it fail when there are some users accessing
the database

------------------------------------------------------------------------------------------------------------------
C. Take a database offline
This example takes the sales database offline if there are no users
accessing the database.

USE master
EXEC sp_dboption 'sales', 'offline', 'TRUE'

"carion1" <dd******@gmail.com> ¼¶¼g©ó¶l¥ó·s»D:uh****************@TK2MSFTNGP14.phx .gbl...
A better link for the offline part:

http://msdn.microsoft.com/library/de...da-di_8c32.asp

--

Derek Davis
dd******@gmail.com

"carion1" <dd******@gmail.com> wrote in message
news:e7**************@tk2msftngp13.phx.gbl...
If you are using SQL Server...

Take it offline:
http://developer.mimer.com/documenta...tements84.html

Restore it:
http://msdn.microsoft.com/library/de...ra-rz_25rm.asp

--

Derek Davis
dd******@gmail.com

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
wrote in message news:Ot**************@TK2MSFTNGP15.phx.gbl...
> ad,
>
> There is no way to do this out of the box. If anything, it depends
> on the database. Most likely, you will have to use some sort of
> administrative interface (there might or might not be one you can
> access programatically, depending on the database) to kick everyone
> off.
>
> Which database are you using?
>
> Hope this helps.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mv*@spam.guard.caspershouse.com
>
> "ad" <fl****@wfes.tcc.edu.tw> wrote in message
> news:%2****************@TK2MSFTNGP12.phx.gbl...
>>I write a restore program to restore a database.
>> But it must stop all connecions to the database before resotre.
>> How can I stop all connecions to the database by program?
>>
>>
>
>



Nov 21 '05 #7
kill [spid]

--

Derek Davis
dd******@gmail.com

"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:Oi*************@TK2MSFTNGP15.phx.gbl...
Thanks,
Could you give me an example?
"carion1" <dd******@gmail.com>
¼¶¼g©ó¶l¥ó·s»D:ek**************@TK2MSFTNGP12.phx.g bl...
Well you could find who is connected to the db in question with sp_who
and then kill those open connections.

--

Derek Davis
dd******@gmail.com

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:OP**************@TK2MSFTNGP15.phx.gbl...
Thanks,
I use the codes below, but it fail when there are some users accessing
the database

------------------------------------------------------------------------------------------------------------------
C. Take a database offline
This example takes the sales database offline if there are no users
accessing the database.

USE master
EXEC sp_dboption 'sales', 'offline', 'TRUE'

"carion1" <dd******@gmail.com>
¼¶¼g©ó¶l¥ó·s»D:uh****************@TK2MSFTNGP14.phx .gbl...
A better link for the offline part:

http://msdn.microsoft.com/library/de...da-di_8c32.asp

--

Derek Davis
dd******@gmail.com

"carion1" <dd******@gmail.com> wrote in message
news:e7**************@tk2msftngp13.phx.gbl...
> If you are using SQL Server...
>
> Take it offline:
> http://developer.mimer.com/documenta...tements84.html
>
> Restore it:
> http://msdn.microsoft.com/library/de...ra-rz_25rm.asp
>
> --
>
> Derek Davis
> dd******@gmail.com
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
> wrote in message news:Ot**************@TK2MSFTNGP15.phx.gbl...
>> ad,
>>
>> There is no way to do this out of the box. If anything, it
>> depends on the database. Most likely, you will have to use some sort
>> of administrative interface (there might or might not be one you can
>> access programatically, depending on the database) to kick everyone
>> off.
>>
>> Which database are you using?
>>
>> Hope this helps.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "ad" <fl****@wfes.tcc.edu.tw> wrote in message
>> news:%2****************@TK2MSFTNGP12.phx.gbl...
>>>I write a restore program to restore a database.
>>> But it must stop all connecions to the database before resotre.
>>> How can I stop all connecions to the database by program?
>>>
>>>
>>
>>
>
>



Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mudge | last post by:
Hi, My hosting provider only allows me to use 50 connections to my MySQL database that my Web site will use. I don't know what this 50 connections means exactly. Does this mean that only 50...
3
by: Sven Jacobs | last post by:
Dear newsgroup, I've upgraded to PEAR::DB 1.6.5 recently. Unfortunately now the database connection doesn't work as expected anymore :( The problems seems to be the method disconnect(), which...
6
by: Toralf Kirsten | last post by:
Hi, we are using db2 8.1 on Linux. I'd like to close all open connection at a defined time point. Therfore I wrote a sql script including the command disconnect all or release all
1
by: Marc Jennings | last post by:
Hi, I need to rebuild a database each time I redeploy a test applicatio, and I was wondering if anyone could give me some clues as to how to go about disconnecting any users that may be logged...
0
by: ad | last post by:
I am use the AttachDbFilename to connection to a .mdf file of SqlExpress (like the example below) After the database is attached, it will be free again until all session time out. But sometime...
0
by: mamod20 | last post by:
Please advise, I have the following example and want to know the best way to use $dbh->disconnect; and $sth->finish; -------------- $sql_host="localhost"; $sql_dataname = "database";...
3
by: Laurence | last post by:
Hi there, Does anyone know what's difference among "connect reset", "disconnect", and "terminate"? Thanks in advance,
1
by: TMAG | last post by:
If i do "db2 disconnect all" after an application finishes, does it mean that any application that connects after this will find the buffer pool "cold"? Or the pages accessed by last application...
9
by: Kelii | last post by:
Currently I have a button that allows the user to "Close Company" - at the moment it doesn't do anything :D I would like the button to "disconnect" the back end then show my Open Company form. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.