在SQL连接期间捕获InvalidOperationExcpetion时该怎么办

时间:2018-08-31 07:28:30

标签: vb.net compact-framework

InvalidOperationException的{​​{1}}方法中,我可以抓住.Open()

SqlConnection

Private Function InsertSomeData() As Boolean Using SqlCon As New SqlConnection(ConnectionString) Try SqlCon.Open() Catch sqlEx as SqlException MessageBox.Show("Error occured while connecting to database!", "Warning", MessageBoxButtons.Ok, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) Return False Catch invOpException As InvalidOperationExcpetion 'what should go here? Connection is open so I just want to continue End Try 'some more code End Using End Function 之后,注释区域应该有什么内容?我什至不希望记录此日志,只是因为某种原因连接已经打开,所以继续。

0 个答案:

没有答案