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? 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?
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?
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?
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?
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? > >
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? >> >> > >
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? >>> >>> >> >> > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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
|
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...
|
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...
|
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";...
|
by: Laurence |
last post by:
Hi there,
Does anyone know what's difference among "connect reset", "disconnect",
and "terminate"?
Thanks in advance,
|
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...
|
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.
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |