473,320 Members | 1,838 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,320 software developers and data experts.

restarting remote SQL server

Below is my code the stop works fine, but then my session is ended. And the rest of the code wont run. I was thinking of making it two different subs, but from the examples in the samples folder I shouln't have to.

Dim srv1 As SQLServer

srv1 = New SQLDMO.SQLServer

If Not srv1 Is Nothing Then

srv1.DisConnect()

srv1 = Nothing

srv1 = New SQLDMO.SQLServer

End If



With srv1

.LoginTimeout = 10

.Name = servername

.Login =

.Password =

.Connect()

End With



'Invoke command to stop server and wait

'until it stops

Select Case srv1.JobServer.Status

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Paused

srv1.JobServer.Stop()

Do Until srv1.JobServer.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

Loop

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

srv1.JobServer.Stop()

Do Until srv1.JobServer.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

Loop

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

MessageBox.Show("SQlAgent is already Stopped")

End Select

Select Case srv1.Status

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Paused

srv1.Shutdown()

Do Until srv1.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

Loop

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

srv1.Shutdown()

Do Until srv1.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

Loop

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

MessageBox.Show("SQlServer is already Stopped")



End Select



'Start jobs back up.

Select Case srv1.JobServer.Status

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Paused

srv1.JobServer.Start()

Do Until srv1.JobServer.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

Loop

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

MessageBox.Show("SQlAgent is already Running")



Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

srv1.JobServer.Start()

Do Until srv1.JobServer.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

Loop

End Select

Select Case srv1.Status

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Paused

srv1.Start(False, srv1.Name)

Do Until srv1.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

Loop

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

MessageBox.Show("SQlAgent is already Running")



Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

srv1.Start(False, srv1.Name)

Do Until srv1.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

Loop

End Select
--
--Eric Cathell, MCSA
Nov 21 '05 #1
1 1819
never mind I figured it out on my own.
--
--Eric Cathell, MCSA
"ECathell" <ec******@nospam.mountaire.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
Below is my code the stop works fine, but then my session is ended. And the rest of the code wont run. I was thinking of making it two different subs, but from the examples in the samples folder I shouln't have to.

Dim srv1 As SQLServer

srv1 = New SQLDMO.SQLServer

If Not srv1 Is Nothing Then

srv1.DisConnect()

srv1 = Nothing

srv1 = New SQLDMO.SQLServer

End If



With srv1

.LoginTimeout = 10

.Name = servername

.Login =

.Password =

.Connect()

End With



'Invoke command to stop server and wait

'until it stops

Select Case srv1.JobServer.Status

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Paused

srv1.JobServer.Stop()

Do Until srv1.JobServer.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

Loop

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

srv1.JobServer.Stop()

Do Until srv1.JobServer.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

Loop

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

MessageBox.Show("SQlAgent is already Stopped")

End Select

Select Case srv1.Status

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Paused

srv1.Shutdown()

Do Until srv1.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

Loop

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

srv1.Shutdown()

Do Until srv1.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

Loop

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

MessageBox.Show("SQlServer is already Stopped")



End Select



'Start jobs back up.

Select Case srv1.JobServer.Status

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Paused

srv1.JobServer.Start()

Do Until srv1.JobServer.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

Loop

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

MessageBox.Show("SQlAgent is already Running")



Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

srv1.JobServer.Start()

Do Until srv1.JobServer.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

Loop

End Select

Select Case srv1.Status

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Paused

srv1.Start(False, srv1.Name)

Do Until srv1.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

Loop

Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

MessageBox.Show("SQlAgent is already Running")



Case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped

srv1.Start(False, srv1.Name)

Do Until srv1.Status = SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running

Loop

End Select
--
--Eric Cathell, MCSA
Nov 21 '05 #2

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

Similar topics

1
by: serge | last post by:
We have an ASP application installed on one powerful Win 2003 and the SQL Server on another Win 2003. We have two copies of the application (identical, one for production and one for test...
0
by: cbielich | last post by:
Here is my problem I create new db in access Link tables from a MySQL server on remote machine to access As long as I dont close access everything works fine. As soon as I close access and...
0
by: Simon Weaver | last post by:
I want to restart IIS from within ASP.NET from a WAP enabled phone. That way if I'm on the beach and the server slows down I can just restart it manually. I'd also like to be able to...
3
by: Jerry Boone | last post by:
I have a development unit running XP Pro and I cannot get it to build a web project without restarting IIS. There errors in the task list are.... ! Could not copy temporary files to the output...
2
by: felecha | last post by:
I'm stumped. I'm working on an application in VB.Net that uses System.Messaging.MessageQueue to listen for messages sent to a private queue on a remote machine. Both machines are in the same...
3
by: Si Chen | last post by:
Hello. It seems that every time I make a change to pg_hba.conf, I have to restart the database server for the new authentication to take effect. Is there a way to have the server use the new...
9
by: walterbyrd | last post by:
I think I have read somewhere that using Python to develop web-applications requires some restarting of the Apache server, whereas PHP does not. Also, I seem to remember reading something about...
1
by: Arif Mohammed | last post by:
Hi, iam using MySql 4.0.1 and jboss-4.0.4.GA Iam getting the following exception when there are more concurrent requests more than 50 in a second Caused by: org.xyz.MyClass: SQL...
8
by: SAL | last post by:
Hello, I have a web app (asp.net 2.0) that I'm loosing Session variables in. I implemented: Application_End in Global.asax using the following code: Sub Application_End(ByVal sender As Object,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.