Results 1 to 5 of 5

Thread: Detail from -- Catch ex As Exception

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Hendersonville , NC
    Posts
    260

    Detail from -- Catch ex As Exception

    My code is such
    Code:
        Public Sub OpenConnection()
            If (Me.con.State = ConnectionState.Closed) Then
                Try
                    Me.con.Open()
                Catch ex As Exception
                    Dim e = TryCast(ex, IContainsErrorRecord)
                    Dim message As String
                    If e IsNot Nothing Then
                        message = e.ErrorRecord.InvocationInfo.PositionMessage
                    Else
                        message = ex.Message
                    End If
                    Console.WriteLine(message)
                    MsgBox(ex.Message)
                    FailureOut = ex.Message
                    YesNo = True
                End Try
            End If
        End Sub
    I am wanting to get the MESSAGEDETAIL property but can't.
    I'm using the Imports System.Management.Automation

    Help please

    Bill
    Last edited by Shaggy Hiker; Oct 26th, 2021 at 08:00 PM. Reason: Added CODE tags.
    William E Gollnick

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,206

    Re: Detail from -- Catch ex As Exception

    If you want more information you can use "ex.ToString"

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Hendersonville , NC
    Posts
    260

    Re: Detail from -- Catch ex As Exception

    Tried that but still could not see the data from the Messagedetail property. Thanks though. .it's closer.
    William E Gollnick

  4. #4
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Re: Detail from -- Catch ex As Exception

    Have you checked the InnerException "ex.InnerException"?
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Hendersonville , NC
    Posts
    260

    Re: Detail from -- Catch ex As Exception

    Quote Originally Posted by KGComputers View Post
    Have you checked the InnerException "ex.InnerException"?
    Yupper.. just tried that.... That itself errored and returned Nothing...
    William E Gollnick

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width