【发布时间】:2017-05-03 14:24:21
【问题描述】:
我正在学习Get Started with Azure Cloud Services 教程。
当我构建并运行示例项目时,出现数据库 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 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 的应用程序 Web.config 文件中的连接字符串 项目和 ServiceConfiguration.Local.cscfg 文件中的 ContosoAdsCloudService 项目。在每种情况下,将“(localdb)\v11.0”更改为“ (localdb)\MSSQLLocalDB"。
在我的
ServiceConfiguration.Local.cscfg:<Setting name="ContosoAdsDbConnectionString" value="Data Source=(localdb)\MSSQLLocalDB; Initial Catalog=ContosoAds; Integrated Security=True; MultipleActiveResultSets=True;" />
如果有人有任何想法或建议,我将不胜感激。谢谢!
【问题讨论】:
-
这个答案对你有帮助吗?也许你没有逃避反斜杠? stackoverflow.com/questions/12463228/…
-
@Jaxidian 谢谢你的建议。我试过了:
<Setting name="ContosoAdsDbConnectionString" value="Data Source=(localdb)\\MSSQLLocalDB; Initial Catalog=ContosoAds; Integrated Security=True; MultipleActiveResultSets=True;" />,但它仍然给出同样的错误。 -
您是否查看了事件日志中的附加信息?
-
实际上,这似乎与您的 Azure 诊断连接字符串有关,但不一定(但可能取决于您的配置?)您的应用程序数据库连接字符串。对于您的应用,它们是一回事吗?
-
@Jaxidian 非常感谢您为此提供的所有帮助。我最终需要继续前进并刚刚安装了 SQL Server Express 2012(请参阅下面的答案)。希望我知道为什么
localdb不起作用,我把我的猜测放在了答案中。
标签: c# sql-server visual-studio azure