无法连接到SQL LocalDB [英] Unable to connect to SQL LocalDB

查看:254
本文介绍了无法连接到SQL LocalDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个本机C ++应用程序,试图在其中使用ADO连接到localdb实例.手动启动实例后,我可以运行sqllocaldb info v11.0并查看数据库实例正在运行.

I have a native C++ app within which I am trying to connect to a localdb instance using ADO. Having manually started my instance I can run sqllocaldb info v11.0 and see the database instance is running.

我的代码如下.

ADO::_ConnectionPtr spConnection (__uuidof (ADO::Connection));
spConnection->Open (L"Provider=SQLNCLI11;Server=(localdb)\\v11.0;Integrated Security=true", L"", L"", 0);

错误代码为DB_E_ERRORSOCCURRED(0x80040e21),错误消息为多步OLE DB操作生成的错误.检查每个OLE DB状态值(如果有).没有任何工作.

The error code is DB_E_ERRORSOCCURRED (0x80040e21) and the error message is Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.

我能够使用SQL Server Management Studio成功连接到数据库,并且在连接字符串中指定是否包含提供程序的情况下都进行了尝试,并且指定了初始目录.

I am able to successfully connect to the database using SQL Server Management Studio and I've tried it both with and without the provider in the connection string as well as specifying an initial catalog.

推荐答案

我发现了我的问题.安全性必须设置为sspi,如下所示.

I found my issue. The security must be set to sspi as shown below.

ADO::_ConnectionPtr spConnection (__uuidof (ADO::Connection));
spConnection->Open (L"Provider=SQLNCLI11;Server=(localdb)\\v11.0;Integrated Security=SSPI", L"", L"", 0);

这篇关于无法连接到SQL LocalDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆