November 20, 2003 at 1:58 am
Hi, I want to restart the server machine thru my VB application. Before that I want to shutdown the database server running in the same machine, again from my VB application. How do I do this.
Request a reply ASAP
Regards,
Harsha
HArsha
HArsha
November 20, 2003 at 2:03 am
I'm pretty sure you'll find a method in the SQL-DMO API.
Have you searched this site?
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
November 20, 2003 at 2:39 am
Have you considered net stop and net start commands?
Jeremy
November 20, 2003 at 3:06 am
yes, both this ways exists !!
net stop MSSQLServer
and
objSQLServer.Shutdown ( TRUE ) -- for normal shutdown
objSQLServer.Shutdown ( FALSE ) -- for immediate shutdown
November 20, 2003 at 3:46 am
Thanks for the replys. I have searched in the site. But I did not find any good answer.
Net Stop I have seen in the help. Ihave some doubts about it
1. Itruns only in command prompt using osql. Isnt't? So we need to write a batch file with this command and run the bat file from VB.
2. It shuts down only the instance which we pass to the command, isn't it. So do I need to run this command for each sessions. Or is it talking about the server instance only, ie. with one command , it shuts down the system?
3. Is there any other way to do the same instead of using osql. But running any commands using ADO in Vb
Thanks again for the fast replys
Regards,
Harsha
HArsha
HArsha
November 20, 2003 at 4:52 am
1. NET STOP is a Windows OS command & not a TSQL command. so you have to run it from a command prompt or bacth file.
2. ADO can shutdown SQL Server instance, but can not bring it up !!!!
3. Shutdown is a process for server & not for individual user sessions. When a shutdown occours, all user processes are rollbacked & terminated by server.
I hope this solved your questions.
November 26, 2003 at 5:39 pm
To shutdown/reboot machine, try:
Set colOperatingSystems = GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Win32Shutdown(6)
Next
ObjOperatingSystem.Win32Shutdown(6)
'6=forced reboot. Change to 12 for forced power off.
See http://www.dandinicolo.com/article.aspx?articleID=280&page=5 for more info, or do search on "win32shutdown".
Bill
November 27, 2003 at 7:21 am
You can use this API function
Public Declare Function StartService Lib "advapi32.dll" Alias "StartServiceA" (ByVal hService As Long, ByVal dwNumServiceArgs As Long, ByVal lpServiceArgVectors As Long) As Long
quote:
Hi, I want to restart the server machine thru my VB application. Before that I want to shutdown the database server running in the same machine, again from my VB application. How do I do this.Request a reply ASAP
Regards,
Harsha
HArsha
November 27, 2003 at 7:33 am
You can use this API function
Public Declare Function StartService Lib "advapi32.dll" Alias "StartServiceA" (ByVal hService As Long, ByVal dwNumServiceArgs As Long, ByVal lpServiceArgVectors As Long) As Long
quote:
Hi, I want to restart the server machine thru my VB application. Before that I want to shutdown the database server running in the same machine, again from my VB application. How do I do this.Request a reply ASAP
Regards,
Harsha
HArsha
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply