Link to home
Start Free TrialLog in
Avatar of djdidge
djdidge

asked on

Application.exit or Process killing

Hi there,

I need to close my application if the db connect fails....  as there is no winforms instance at this point i am led to believe that application.exit will not work. So i believe i need to process.kill        

But im not sure of the syntax.

    Private Sub connectDB()
        Try
            conSQL = New SqlConnection()
            conSQL.ConnectionString = "Password=oioi;Persist Security Info=True;User ID=meme;Initial Catalog=dbInstance;Data Source=server"
            AddHandler conSQL.InfoMessage, New SqlInfoMessageEventHandler(AddressOf conSQL_infomessage)
            conSQL.Open()
        Catch
            MsgBox("Failed to connect to database server", , "Application will exit")
            Application.Exit()
        End Try
    End Sub

    Public Sub Main()
        Try
            connectDB()
            PrepComm()
        Catch ex As Exception
            MsgBox(ex.toString)
            Exit Sub
        End Try

        Application.Run()
    End Sub

Sorry about the low points... my last 85! :o/
ASKER CERTIFIED SOLUTION
Avatar of Fahad Mukhtar
Fahad Mukhtar
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of djdidge
djdidge

ASKER

thx