Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 333
  • Last Modified:

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/
0
djdidge
Asked:
djdidge
1 Solution
 
Fahad MukhtarDistinguished EngineerCommented:
you can use
Environment.Exit(Environment.ExitCode)
0
 
djdidgeAuthor Commented:
thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now