• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

App crashing and I dont know why

Ive been working on a sql app for a few weeks and its nearing completion, but during some final testing I stumbled on a bug that makes the app crash for no reason. Keep in mind that it works fine when the SQL server is running but when I stop it to check for error handling it returns the usual "Sql server does not exist or access is denied" but once I click OK it just closes out...no additonal messages or anything. Here is the code that is called from a menu on an mdi form

// Begin

Private Sub CreateTable()

        Dim strSQL As String = _
            "IF EXISTS (" & _
            "SELECT * " & _
            "FROM master..sysdatabases " & _
            "WHERE Name = 'UserAudit')" & vbCrLf & _
            "DROP DATABASE UserAudit" & vbCrLf & _
            "CREATE DATABASE UserAudit"

        Dim frmStatusMessage As New frmStatus

        frmStatusMessage.MdiParent = Me.MdiParent
        frmStatusMessage.Show("Connecting to SQL Server")

            Dim SqlConnection As New SqlConnection(connectionstring)
            Dim cmd As New SqlCommand(strSQL, SqlConnection)


            msg = "Database 'UserAudit' successfully created!"
            style = MsgBoxStyle.DefaultButton1 Or _
            MsgBoxStyle.Information Or MsgBoxStyle.OKOnly
            title = "Database Creation"
            response = MsgBox(msg, style, title)

        Catch ex As Exception
            msg = ex.Message
            style = MsgBoxStyle.DefaultButton1 Or _
            MsgBoxStyle.Critical Or MsgBoxStyle.OKOnly
            title = "Connection Failed"
            response = MsgBox(msg, style, title)
        End Try
    End Sub

// End

Thanks for any help you guys can give.
1 Solution
Hi this

            response = MsgBox(msg, style, title)
        End Try
    End Sub

should be

            response = MsgBox(msg, style, title)
        End Try
    End Sub

the seperate End will end your app
JoeDWAuthor Commented:
Wow, I feel bad that I missed that one. Thanks alot because I completely overlooked that, it hadnt even dawned on me that it would be the cause.

Thanks again for the help

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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