Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • 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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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