在C ++ / .NET中使用SqlConnection [英] using a SqlConnection in C++ / .NET
问题描述
当我访问 MSDN 页面为 SqlConnection
类,它只显示了C#和VB中的示例。为什么MSDN不显示C ++示例?
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?
我特别感兴趣的是C ++示例如何解决 code> C ++中的关键字。
I am particularly interested in how a C++ example would get around the lack of the using
keyword in C++.
推荐答案
Hmmm ...在阅读什么是Managed C ++等同于C#using语句。相当于:
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...
}
实际上是:
{
SqlConnection conn(connectionString);
// SqlCommand and so...
}
这是相当令人印象深刻的,因为C ++不缺少使用
语句,因为它完全不需要它!我不认为C#/ VB程序员充分认识到C ++的优势(我当然没有:)。
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 :) .
这篇关于在C ++ / .NET中使用SqlConnection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!