The 'SQLNCLI' provider is not registered on the local machine

回眸只為那壹抹淺笑 提交于 2019-11-29 06:12:39

问题


I have a NAnt-based script which that I run on my local PC that connects to SQL Server 2008 Express also running on my local PC to drop and recreate databases using .sql files - this works fine, no problem here.

The problem comes when I have recreated the same set-up on another PC, I get the error in my NAnt script saying that:

System.InvalidOperationException: The 'SQLNCLI' provider is not registered on the local machine.
  at System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper)
  at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
  at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
  at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
  at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
  at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
  at System.Data.OleDb.OleDbConnection.Open()
  at NAnt.Contrib.Util.SqlHelper..ctor(String connectionString, Boolean useTransaction)
  at NAnt.Contrib.Tasks.SqlTask.ExecuteTask()
  at NAnt.Core.Task.Execute()
  at NAnt.Core.Target.Execute()
  at NAnt.Core.Project.Execute(String targetName, Boolean forceDependencies)
  at NAnt.Core.Project.Execute()
  at NAnt.Core.Project.Run()

I have searched online and have found that in a forum it was suggested that I needed to install the Microsoft SQL Server Native Client, and got it from this URL. (Admittedly, I have only installed the Native Client part of this)

Despite this being installed on my second PC, the script still gives me the same error. Any suggestions?


回答1:


The correct provider for SQL Server 2008 is SQLNCLI10.1.
For SQL Server 2012, that would be SQLNCLI11. (source)

Sadly, the migration to 2008 did not pick up the change...




回答2:


Could it be a problem with x86/x64? If the workstation in question is x64, and you've installed the x64 version of the client, but the application you're trying to run is in the x86 space, you may need the x86 version of the client on that workstation as well. An x86 app will only check for an x86 version of the provider, and seeing none, will give an error like this one. The x64 version is probably smart enough to check for either version, though maybe you'd have the same situation.

This same thing happens with ODBC - x86 and x64 data sources aren't available to the other type of application - if you want something to be visible from both builds of applications, you'll need to create an ODBC source in each version's Admin tool.



来源:https://stackoverflow.com/questions/1482095/the-sqlncli-provider-is-not-registered-on-the-local-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!