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 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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

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.