C# Azure Contoso Ads教程-无法连接到localdb
我正在浏览教程 构建和运行示例项目时,数据库I/O错误为:C# Azure Contoso Ads教程-无法连接到localdb,c#,sql-server,visual-studio,azure,C#,Sql Server,Visual Studio,Azure,我正在浏览教程 构建和运行示例项目时,数据库I/O错误为: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is confi
A network-related or instance-specific error occurred while establishing a
connection to SQL Server. The server was not found or was not accessible.
Verify that the instance name is correct and that SQL Server is configured
to allow remote connections. (provider: SQL Network Interfaces, error: 50 -
Local Database Runtime error occurred. Cannot create an automatic instance.
See the Windows Application event log for error details.)
VS.NET 2017
,并且确实进行了建议的更改:
如果您使用的是Visual Studio 2015或更高版本,请更改SQL Server
ContosoAdsWeb的application Web.config文件中的连接字符串
项目的ServiceConfiguration.Local.cscfg文件中
ContosoAdsCloudService项目。在每种情况下,将“(localdb)\v11.0”更改为“
(localdb)\MSSQLLocalDB”
在myServiceConfiguration.Local.cscfg
中:
<Setting name="ContosoAdsDbConnectionString" value="Data Source=(localdb)\MSSQLLocalDB; Initial Catalog=ContosoAds; Integrated Security=True; MultipleActiveResultSets=True;" />
localdb
是否存在,并且可以连接到:
最后,我在上面下了赌注,安装了SQL Server 2012 Express edition,并使用了连接字符串:
<Setting name="ContosoAdsDbConnectionString" value="Data Source=MACHINE_NAME\SQLEXPRESS;
Initial Catalog=ContosoAds; Integrated Security=True; MultipleActiveResultSets=True;" />
这很有效
我唯一能想到的是我正在运行Windows7
和VisualStudio2017
我相信
VS.NET 2017
可能会捆绑SQL Server 2016
,我知道它与Windows 7
不兼容这个答案对您有帮助吗?也许你没有逃过反斜杠@谢谢你的建议。我尝试了:
,但是它仍然给出相同的错误。您是否查看了事件日志中的其他信息?实际上,这似乎与Azure Diagnostics connectionstring有关,而不一定(但可能取决于您的配置)与应用程序db connectionstring有关。它们对你的应用程序来说是一样的吗?@Jaxidian非常感谢你在这方面的帮助。我最终需要继续前进,只安装了SQL Server Express 2012(请参阅下面的答案)。希望我知道为什么localdb
不起作用,我在答案中加入了我的猜测。祝贺你!但这似乎不是localdb的连接字符串。作为其他人的简单参考,我将同时使用Windows7 ultimate 64位和SQL Server 2016。