Login Problem ??

  • Hi !!!

    I am connecting to SQL SERVER with following VB code :-

    Set SQLInstance = New SQLDMO.SQLServer

    ' Log in

    SQLInstance.LoginSecure = True

    SQLInstance.Connect "serverName","userid","pwd"

    This code works proprerly if the server is already on,but if server is off I get error

    Can anyone suggest any method to detect whether Server is on or off.

    Thanx

    SP

  • Couple ideas:

    Use a try-catch block to catch a failed Connect call.  You should probably set a reasonable LoginTimeout value first.

    I believe you could use SQLInstance.Status to check whether the service is actually responding.  Again you may need a try-catch block to catch a service unreachable error.

    JR

  • Can u give me VB code for try catch block??

    I am still finding the solution for my prob.

    thanx

    SP

  • this can work for vb.net

    Try

    [ tryStatements ]

    [ Catch [ exception [ As type ] ] [ When expression ]

       [ catchStatements ] ]

    [ Exit Try ]

    ...

    [ Finally

       [ finallyStatements ] ]

    End Try

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply