473,805 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7194
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.co m

"ad" <fl****@wfes.tc c.edu.tw> wrote in message
news:%2******** ********@TK2MSF TNGP12.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.c om> wrote in
message news:Ot******** ******@TK2MSFTN GP15.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.co m

"ad" <fl****@wfes.tc c.edu.tw> wrote in message
news:%2******** ********@TK2MSF TNGP12.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******** ******@tk2msftn gp13.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.c om> wrote
in message news:Ot******** ******@TK2MSFTN GP15.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.co m

"ad" <fl****@wfes.tc c.edu.tw> wrote in message
news:%2******** ********@TK2MSF TNGP12.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************* ***@TK2MSFTNGP1 4.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******** ******@tk2msftn gp13.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.c om> wrote
in message news:Ot******** ******@TK2MSFTN GP15.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.co m

"ad" <fl****@wfes.tc c.edu.tw> wrote in message
news:%2******** ********@TK2MSF TNGP12.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.ed u.tw> wrote in message
news:OP******** ******@TK2MSFTN GP15.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************* ***@TK2MSFTNGP1 4.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******** ******@tk2msftn gp13.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.c om> wrote
in message news:Ot******** ******@TK2MSFTN GP15.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.co m

"ad" <fl****@wfes.tc c.edu.tw> wrote in message
news:%2******** ********@TK2MSF TNGP12.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.gbl...
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.ed u.tw> wrote in message
news:OP******** ******@TK2MSFTN GP15.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************* ***@TK2MSFTNGP1 4.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******** ******@tk2msftn gp13.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.c om>
wrote in message news:Ot******** ******@TK2MSFTN GP15.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.co m
>
> "ad" <fl****@wfes.tc c.edu.tw> wrote in message
> news:%2******** ********@TK2MSF TNGP12.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.tc c.edu.tw> wrote in message
news:Oi******** *****@TK2MSFTNG P15.phx.gbl...
Thanks,
Could you give me an example?
"carion1" <dd******@gmail .com>
¼¶¼g©ó¶l¥ó·s»D: ek************* *@TK2MSFTNGP12. phx.gbl...
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.ed u.tw> wrote in message
news:OP******** ******@TK2MSFTN GP15.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************* ***@TK2MSFTNGP1 4.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******** ******@tk2msftn gp13.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.c om>
> wrote in message news:Ot******** ******@TK2MSFTN GP15.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.co m
>>
>> "ad" <fl****@wfes.tc c.edu.tw> wrote in message
>> news:%2******** ********@TK2MSF TNGP12.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
2415
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 visitors to my Web site can access my database through my Web site at one time? Or does this mean that in my code I can only use 50 connections? and like
3
2896
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 now closes the database connections of _all_ database objects. I ask myself if this is intentional or a bug. Below a code example: 01 <?php 02   error_reporting(E_ALL);
6
28213
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
3733
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 into that database in SQL. I know I can do this quite easily using MSBuild, but the reason I need to know is so I can get awayt from using beta tools in development. (We have a specific issue with MSBuild) Also, if anyone knows of a good...
0
1023
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 I want to move the .mdf file to another place, but the .mdf is not free. How can I disconnect all the connections to that database immediately?...
0
3816
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"; $sql_userid = "root"; $sql_password = "password"; &connect_sql;
3
45517
by: Laurence | last post by:
Hi there, Does anyone know what's difference among "connect reset", "disconnect", and "terminate"? Thanks in advance,
1
3858
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 will be still in buffer pool? Apparently when I do "db2 disconnect all" at the end, the windows task manager shows that all bufferpool memory has been deallocated. thanks
9
8605
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. My question is: 1. Short of closing the application or deleting the linked tables, is there a way to disconnect the user's front end from the common back end using VBA? 2. Does disconnecting the user serve any purpose? I've read a lot of posts...
0
9718
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10614
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10109
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.