Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Starting SQL Server through SQLDMO

Status
Not open for further replies.

puthran

Programmer
Joined
Apr 4, 2003
Messages
3
Location
IN
Hi,
I have SQLServer2000 installed on a machine and i'm using it as a server. In the client machine i'm using SQLDMo to start the SQLServer service. When i use the start method i get an error 'Access Denied'. But when i run the same code in the server machine, it works fine. Can someone tell me how to make this work even in the client machine. I have created a User in the server and given DBA rights. I'm using the User Name of PWD of this user in the start method.

REgards,
Vishrant
 
You should post your code so we can have a look. With that said here is the code that I use to connect to a remote server from the SQL server client.

Dim l_sngTime As Single, l_sngPauseTime As Single
Dim objServer As SQLDMO.SQLServer

DoEvents
pgbServer.Value = 0
'// Connect to the server.
Set objServer = New SQLDMO.SQLServer
objServer.Name = pServerName
If objServer.Status = SQLDMOSvc_Stopped Then
objServer.Start True, <pServerName>, <pUserName>, <pPassword>
DoEvents
l_sngTime = Timer
l_sngPauseTime = (60 * 3)
Do
If Timer > l_sngTime + l_sngPauseTime Then Exit Do
Loop Until objServer.Status = SQLDMOSvc_Running
Else
objServer.LoginSecure = <pSecure>
objServer.Connect <pServerName>
End If

pServerName - the name of the SQL Server on which the database resides.
pUserName - the user name used to logon to the server.
pPassword - the password used to logon to the server.
pSecure - boolean used in determining how to login when connecting. If True use NT authentication.

And, as you said, the NT user has to exist as a user on the server and have dbOwner rights (well, that's what I give them). They may also need to have administrative rights on their local machine, I don't remember if I tested that. Thanks and Good Luck!

zemp
 
Hi Zemp,
Thanks for the reply. I have posted my code for your reference.

Private Sub subStartServer(ByVal strServer As String, ByVal strDBOName as String, _
ByVal strDBOPWD As String)

Dim objSQLDMO As New SQLDMO.SQLServer

On Error GoTo ErrorHandler

If objJobServer.Status = SQLDMOSvc_Stopped Then
objSQLDMO.Start False, strServer, strDBOName,strDBOPWD
End if

Set objSQLDMO = Nothing

Exit Sub
ErrorHandler:
' log the errors
berror = True
Call subErrorFunction(&quot;subStartServer&quot;)
End Sub

As you can see, its the same as what you have posted except that i haven't used Events. I think this has something got to do with giving Access rights either in SQL2000 or Windows2000.

Thanks,
Visrhant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top