Is this possible using a using statement C# SQL?
private static void CreateCommand(string queryString,
string connectionString)
{
using (SqlConnection connection = new SqlConnection(
connectionString))
{
SqlCommand command = new SqlCommand(queryString, connection);
command.Connection.Open();
command.ExecuteNonQuery();
}
}
What if there’s a error while opening the connection?
The using statement is try and finally
No catch
So if I catch outside the using brackets will the catch catch the connection opening error?
If not, how to implement this with using the using
statement a shown above?