我正在尝试在进入下一个表单之前处理登录错误,并且在大多数情况下,一切正常。我遇到了一个问题 - 当网络连接未建立时,ODBC 驱动程序会提供自己丑陋的错误消息。
这是我的代码:
Try
ODBCconnection.Open()
ODBCconnection.Close()
Me.Hide()
otherForm.ShowDialog()
Catch ex As Exception
If ex.Message.IndexOf("ugly network problem message") > -1 Then
MsgBox("fancy network problem message")
ElseIf ex.Message.IndexOf("other error message") > -1 Then
MsgBox("fancy other error message")
End If
End Try
所以,如果“other error message”被捕获,它会显示“fancy other error message”,但如果“ugly network problem message”被捕获,它会同时显示丑陋和花哨的错误消息。
我认为驱动程序本身正在生成一条消息,关于如何抑制它的任何想法?