C# try catch confusion
问题 I'm very new to C#. When I try catch something like this: try { connection.Open(); command.ExecuteNonQuery(); } catch(SqlException ex) { MessageBox.Show("there was an issue!"); } How do I know if the problem happened with the Open or ExecuteNonQuery ? What if I called a bunch of other non-SQL stuff in the Try ? How would I know which failed? What does SqlException mean over regular Exception ? How would SqlException handle non-SQL related errors if I had such code in the Try block? 回答1: You