Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get a list of all running sql servers?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00673392
Message ID:
00674119
Views:
24
Here is some code I hacked out of SQL-DMO help file
LOCAL oApp as SQLDMO.Application
oApp = Createobject("SQLDMO.Application")

oNames = oApp.ListAvailableSQLServers()
Set Step On
*on error resume next

For Each oName In oNames
LOCAL oServer as SQLDMO.SQLServer
oServer = Createobject("SQLDmo.SqlServer")
oserver.ConnectionID = << Needs your method of connecting here

oServer.LoginSecure = .t.
oServer.Connect( oName)
If err.Number <> 0 then
strErrorMsg = strErrorMsg && "" & vbCRLF
strErrorMsg = strErrorMsg && "trouble connecting to " & oName & vbCRLF
strErrorMsg = strErrorMsg && "" & vbCRLF

err.Clear
writefile("C:\sqlbackupinfo.txt",strErrorMsg)
strErrorMsg = ""
EndIf
strDBBackupList = ""
objDBList = new clsServerBackupInfoList
objDBList.SQLServer = oName
strDBBackupList = strDBBackupList & objDBList.SQLServer & vbCRLF
While Not objDBList.Eof
strDBBackupList = strDBBackupList & objDBList.Database & vbTab
objDBInfo = new clsDBBackupInfo
objDBInfo.SQLServer = objDBList.SQLServer
objDBInfo.Database = objDBList.Database
strDBBackupList = strDBBackupList & "Last Backup: " & objDBInfo.StartTime & " Result " & objDBInfo.Success & " " & objDBInfo.Message & " " & objDBInfo.Plan & vbCRLF
objDBInfo = null
objDBList.MoveNext
*wend
*call writefile("C:\sqlbackupinfo.txt",strDBBackupList)
objDBList = Null
Next

oServer.DisConnect
oServer = Null

oApp.Quit
oApp = Null
End
endfor

>Could you post the code?
>
>>>I would like to add a combo-box to a form that would display all of the sql servers on the network. Right now, I have some code that I can use to populate the control from the defined data sources (odbc, dsn, etc.) but I would like to also allow the user to select a specific Sql server.
>>>
>>>Thanks...Douglas
>>
>>Replying to myself and anyone else interested....but I figured out how to do this. I found some VB code that I translated for VFP. Now, my only problem is how to figure out why one of the sql servers is not advertising itself on our network.
>>....douglas
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform