It used to be asey in VB6 to trap for a particular error number but not now.
I want to trap for the failure of a SQL connection. Since there can be many reasons for failure I want to trap by the error number.
I found it during runtime in what looked like ex.innermessage.number but I cant get to it. How do I do it properly?

TIA.

VB Code:
  1. '<CONNECT TO SQL DB>
  2. Try
  3.     goSQLConn = New SqlConnection
  4.     goSQLConn.ConnectionString = "Data Source=MyServer;Initial Catalog=MyDB;Integrated Security=SSPI;"
  5.     goSQLConn.Open()
  6. Catch ex As Exception
  7.     If ex.number = 4060 Then '<-- no dice :(
  8.  
  9.     End If
  10. End Try
  11. '</CONNECT TO SQL DB>