1

When I go to the MSDN page for the SqlConnection class, it only shows examples in C# and VB. Why doesn't MSDN show a C++ example?

I am particularly interested in how a C++ example would get around the lack of the using keyword in C++.

3

1 Answer 1

1

Hmmm... after reading What is the Managed C++ equivalent to the C# using statement it seems that the equivalent of:

using (SqlConnection connection = new SqlConnection(connectionString))
{
    // SqlCommand and so...
}

is actually:

{
  SqlConnection conn(connectionString);

  // SqlCommand and so...
}

That is quite impressive, since C++ does not "lack" theusing statement as much as it removes the need for it entirely! I don't think that C#/VB programmers sufficiently appreciate that advantage of C++ (I certainly didn't :) .

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.