如果我没有安装本机客户端,Visual Studio 2010 如何连接到 SQL Server 2008?

发布于 2024-12-10 23:48:36 字数 453 浏览 0 评论 0原文

我在 Windows 7 上安装了 MS VS 2010,但是没有安装 SQL Server Native 客户端。

加载 Visual Studio 后,我单击菜单“数据”/“Transact-SQL 编辑器”/“新建查询连接”。

将显示 SQL Server 2008 R2 登录对话框,我键入服务器名称,选择 SQL Server 身份验证,键入用户名和密码,然后单击连接。连接已建立,编辑器窗口出现,我已准备好查询!

据我所知,SQL Server 2008本机客户端文件是sqlncli10.dll、sqlnclir10.rll。我确实在整个硬盘中搜索了这些文件,但没有找到。

那么,如果我没有安装本机客户端,Visual Studio 2010 如何连接到 SQL Server 2008?

连接到 SQL Server 2008 时,VS 2010 是否使用 .NET Framework 程序集?

I have MS VS 2010 installed on my Windows 7 but, I don't have the SQL Server Native client installed in it.

After loading Visual Studio I do click menu Data / Transact-SQL Editor / New Query Connection.

The SQL Server 2008 R2 login dialog will show up, I type server name, select SQL Server authentication, type username and password and click connect. The connection is established and an editor window shows up and I'm ready to query!

I understand the SQL Server 2008 native client files are sqlncli10.dll, sqlnclir10.rll. I did search for these files in my entire hard drive and they weren't found.

So, how is Visual Studio 2010 connecting to SQL Server 2008 if I don't have the native client installed?

Is VS 2010, when connecting to SQL Server 2008, using .NET Framework assemblies?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

白色秋天 2024-12-17 23:48:36

.NET Framework 已包含 Sql Server(和其他)数据库客户端。
看看System.Data.SqlClient

The .NET Framework already contains the Sql Server (and other) Database clients.
Have a look at System.Data.SqlClient

陌上芳菲 2024-12-17 23:48:36

如果未安装本机客户端,则在通过菜单“数据/Transact-SQL 编辑器/新建查询连接”进行连接时,Visual Studio 2010 将使用 .NET Framework 版本 4.0 连接到 SQL Server 2008 R2。

我验证了它正在加载程序集 System.Data.dll(位于 C:\Windows\Microsoft.NET\Framework\v4.0.30319 下)以建立与服务器的连接。

我还没有安装 SQL Server 2008 R2 的本机客户端 10.0,现在也没有使用它,但是如果安装了,应该可以在以下位置找到本机客户端文件(sqlncli10.dll、sqlnclir10.rll 和 s10ch_sqlncli.chm

%SYSTEMROOT%\system32\

)作为 SQL Server 安装的一部分进行安装。

还有一个名为 sqlncli.msi 的可再发行安装程序,可以在 SQL Server 安装 CD 上的

%CD%\Setup\

安装详细信息参考

http://msdn.microsoft.com/en-us/library/ms131321.aspx

以及 SQL Server 2008 的参考R2 本机客户端功能

http://msdn.microsoft.com/en-us/library /ms131456.aspx

If NO native client is installed, Visual Studio 2010 is using the .NET Framework version 4.0 to connect to SQL Server 2008 R2 when connecting through menu Data/Transact-SQL Editor/New Query Connection.

I verified and it is loading assembly System.Data.dll (located under C:\Windows\Microsoft.NET\Framework\v4.0.30319) to establish the connection to the server.

I have not installed the Native client 10.0 for SQL Server 2008 R2 and I'm not using it right now but, if installed, the native client files (sqlncli10.dll, sqlnclir10.rll, and s10ch_sqlncli.chm) should be found under

%SYSTEMROOT%\system32\

which are installed as part of the SQL Server installation.

There is also a redistributable installation program named sqlncli.msi, which should be found on the SQL Server installation CD under

%CD%\Setup\

The reference for installation details

http://msdn.microsoft.com/en-us/library/ms131321.aspx

And the reference for the SQL Server 2008 R2 Native Client Features

http://msdn.microsoft.com/en-us/library/ms131456.aspx

初熏 2024-12-17 23:48:36

这里的关键信息是:

您不需要在客户端计算机(在本例中是 Visual Studio 所在的开发盒)上安装 SQL Server Native Client,以便使用 ADO.Net 的应用程序连接到 SQL Server 。

原因正如 @dknaack 所说:.Net 框架包含建立连接所需的代码。它包含在 System.Data.SqlClient 中。

另一方面,非托管应用程序使用 SQL Native Client 通过 OleDB 或 ODBC 提供程序连接到 SQL Server。

简而言之:

System.Data.SqlClient - 用于从托管代码到 SQL Server 的连接,即 ADO.Net 连接
SQL Server Native Client - 用于从非托管代码到 SQL Server 的连接

虽然您可以使用 SQL Server Native Client 从托管应用程序连接到 SQL Server,但不建议这样做:

如果您正在开发新的应用程序,建议您
考虑使用 ADO.NET 和 .NET Framework Data Provider for SQL
Server代替SQL Server Native Client来访问所有新的
SQL Server 最新版本的功能。

参考:
https://learn.microsoft.com/en-us/sql/relational-databases/native-client/sql-server-native-client-programming?view=sql-server-2017

https://learn.microsoft.com/en-us/sql/relational-databases/native-client/applications/using-ado-with-sql-server-native-client?view=sql-server-2017

The key piece of information here is:

You do not need to install SQL Server Native Client on your client machine (in this case your dev box where Visual Studio is), in order for an application using ADO.Net, to connect to SQL Server.

The reason is as @dknaack said: the .Net framework contains the code required to make the connection. This is contained in System.Data.SqlClient.

SQL Native Client on the other hand is used by unmanaged applications to connection to SQL Server via either OleDB or ODBC providers.

In short:

System.Data.SqlClient - used for connections from managed code to SQL Server i.e an ADO.Net connection
SQL Server Native Client - used for connections from unmanaged code to SQL Server

Whilst you CAN connect to SQL Server from a managed app using SQL Server Native Client, it is not a recommended practice:

If you are developing a new application, it is recommended that you
consider using ADO.NET and the .NET Framework Data Provider for SQL
Server instead of SQL Server Native Client to access all the new
features of recent versions of SQL Server.

References:
https://learn.microsoft.com/en-us/sql/relational-databases/native-client/sql-server-native-client-programming?view=sql-server-2017

https://learn.microsoft.com/en-us/sql/relational-databases/native-client/applications/using-ado-with-sql-server-native-client?view=sql-server-2017

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文