VBA Error handling on ADODB Connection.Open
问题 I have an ADODB connection in VBA for connecting to an SQLServer database. I want to catch the error that is raised when connection.Open is called and the given database is unreachable. My code looks like this: Public Function Connect() As Boolean On Error GoTo DBError Dim dbServer As String Dim dbName As String Dim dbUser As String Dim dbPwd As String dbServer = DatabaseSettings.dbServer dbName = DatabaseSettings.dbName dbUser = DatabaseSettings.dbUser dbPwd = DatabaseSettings.dbPwd Dim