且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

连接字符串 - 无效的Connectionstring属性

更新时间:2023-11-06 10:18:10

您好MrAvgProgrammer,


感谢您在此处发帖。


根据您的描述,我发现您使用的是提供商"SQLNCLI" ;(SQL Server Native Client OLE DB)。如您所知,SQL Server Native Client OLE DB(SQLNCLI)仍然不建议使用,因此不建议将其用于新的开发工作。
而是使用新的Microsoft OLE DB驱动程序用于SQL Server(MSOLEDBSQL),它将使用最新的服务器功能进行更新。


参考:


使用连接字符串关键字和SQL Server的OLE DB驱动程序


***的问候,




[SQL Server 2008 R2 Express]
I have used this connection string for about 4 years now and I will intermittently receive an error message:

-2147467259 : Microsoft SQL Server Native Client 10.0
Invalid connection string attribute

"Provider=SQLNCLI10;Persist Security Info= True;OLE DB Services = -2;User ID=USERNAME;Password=PASSWORD;Initial Catalog=MYDB;Query Wait=-1;Data Source=WORK\MYINSTANCE"

The connection to the database seems to work fine (updates, selects, inserts, all work still).  I dont see anything that is obviously wrong.  I am also not sure why this CS works sometimes and not others.

The only 2 possible issues I could see is the Query Wait and OLE DB Services = -2

Query Wait is default -1, but I set it anyways as a safe guard. Wouldn't think that is an issue.

I am not sure why I have OLE DB set to -2, as noted on this site, there is no -2....So I am not quite certain if that is the source of my issue.
https://docs.microsoft.com/en-us/cpp/data/oledb/overriding-provider-service-defaults?view=vs-2019
My understanding is that this is Disabling connection pooling...
Any suggestions or ideas would greatly be appreciated.


Hi MrAvgProgrammer,

Thanks for posting here.

Per your description, I see that you are using the Provider "SQLNCLI"(SQL Server Native Client OLE DB). As you know, the SQL Server Native Client OLE DB (SQLNCLI) remains deprecated and it is not recommended to use it for new development work. Instead, use the new Microsoft OLE DB Driver for SQL Server (MSOLEDBSQL) which will be updated with the most recent server features.

Reference:

Using Connection String Keywords with OLE DB Driver for SQL Server

Best Regards,

Will