如果我需要在同一数据库的3个表上记录数据,接下来的两种方式对我来说是一样的
坐着1
Try
Using (conn)
conn.Open()
Try
'Handle Table 1
Catch ex As Exception
MsgBox(ex.ToString())
End Try
Try
'Handle Table 2
Catch ex As Exception
MsgBox(ex.ToString())
End Try
Try
'Handle Table 3
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Using
Catch ex As Exception
MsgBox(ex.ToString())
End Try
嵌套2 使用块是主要的
Using conn As New SQLiteConnection(SQLiteConnStr)
Try
conn.Open()
Try
'Handle Table 1
Catch ex As Exception
MsgBox(ex.ToString())
End Try
Try
'Handle Table 2
Catch ex As Exception
MsgBox(ex.ToString())
End Try
Try
'Handle Table 3
Catch ex As Exception
MsgBox(ex.ToString())
End Try
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Using
两种方式相同或一种方式更好,因为更好地处理“Catch ex as Exception?