That does work indeed. I am finding that however when you set your connection string in the app.config file the catch exception is "object not set to an instance..." even for type SQLException. Or even if you have the following you will get the same exception message "object not set..."
declare str as string
declare connectionString as string = "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=HospitalMgt;Integrated Security=True;"
try
perform using connection as type SqlConnection = new SqlConnection(connectionString)::ConnectionString
invoke connection::Open