如何快速判断SQL服务器是否开机
如何快速判断SQL服务器是否开机呢?用SQLSTRINGCONNECT()>0 来判断,如果联通会很快,如果没开机会等半天,有没有更快的办法呢?
Function VfpPing Lparameters tcWhere, tnWhichPort Local lReturnValue * [color=#0000FF]by josh@jassing.com[/color] * [color=#0000FF]with LOTS of help from (actually; all the hard work by) Markus Voellmy[/color] * wrapped up [color=#0000FF]as a big function by Lou Harris[/color] * * ? pingstate( pingx( "www.,[color=#800000]80 ) )[/color] * would [color=#0000FF]check to be sure it's running a web server * NOTE: it does not do any dns lookups; so if you[/color]'re checking for a mail server, you need * [color=#0000FF]to resolve the mx record yourself.[/color] If Vartype(tnWhichPort) # "N" tnWhichPort = 80 Endif *? pingstate( pingx( "www.,80 ) ) lReturnValue = pingstate( pingx( m.tcWhere, m.tnWhichPort ) ) Return m.lReturnValue #Define sckClosed 0 #Define sckOpen 1 #Define sckListening 2 #Define sckConnectionPending 3 #Define sckResolvingHost 4 #Define sckHostResolved 5 #Define sckConnecting 6 #Define sckConnected 7 #Define sckClosing 8 #Define sckError 9 Endfunc Function pingstate Lparameters tnState Local lcState Do Case Case tnState = sckClosed lcState = "Closed" Case tnState = sckOpen lcState = "Open" Case tnState = sckListening lcState = "Listening" Case tnState = sckConnectionPending lcState = "Waiting" Case tnState = sckResolvingHost lcState = "Resolving" Case tnState = sckConnecting lcState = "Connecting" Case tnState = sckConnected lcState = "Connected" Case tnState = sckClosing lcState = "Closing" Case tnState = sckError lcState = "Error" Otherwise lcState = "Unknown" Endcase Return lcState Endfunc Function pingx Lparameters tcServer, tnPort Local lnState, loPing, lnLast loPing=Createobject("mswinsck.winsock") With loPing .remoteport = tnPort .remotehost = tcServer .Connect() lnLast = -1 Do While .state < sckConnected If lnLast # .state lnLast = .state Endif Enddo lnState = .state .Close() Endwith Return lnState