简体   繁体   中英

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

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?

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

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 ie 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://docs.microsoft.com/en-us/sql/relational-databases/native-client/sql-server-native-client-programming?view=sql-server-2017

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM