【问题标题】:Azure Contoso Ads Tutorial - cannot connect to localdbAzure Contoso 广告教程 - 无法连接到 localdb
【发布时间】: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.)
  1. 我正在运行 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;" />
    
  2. 我验证了 SQL Express localdb 存在并且可以连接到:

如果有人有任何想法或建议,我将不胜感激。谢谢!

编辑: Windows 应用程序日志错误(同样的错误,只是重复了几次)

【问题讨论】:

  • 这个答案对你有帮助吗?也许你没有逃避反斜杠? stackoverflow.com/questions/12463228/…
  • @Jaxidian 谢谢你的建议。我试过了:&lt;Setting name="ContosoAdsDbConnectionString" value="Data Source=(localdb)\\MSSQLLocalDB; Initial Catalog=ContosoAds; Integrated Security=True; MultipleActiveResultSets=True;" /&gt;,但它仍然给出同样的错误。
  • 您是否查看了事件日志中的附加信息?
  • 实际上,这似乎与您的 Azure 诊断连接字符串有关,但不一定(但可能取决于您的配置?)您的应用程序数据库连接字符串。对于您的应用,它们是一回事吗?
  • @Jaxidian 非常感谢您为此提供的所有帮助。我最终需要继续前进并刚刚安装了 SQL Server Express 2012(请参阅下面的答案)。希望我知道为什么localdb 不起作用,我把我的猜测放在了答案中。

标签: c# sql-server visual-studio azure


【解决方案1】:

我最终选择了这个并安装了 SQL Server 2012 Express 版本并使用了连接字符串:

<Setting name="ContosoAdsDbConnectionString" value="Data Source=MACHINE_NAME\SQLEXPRESS; 
Initial Catalog=ContosoAds; Integrated Security=True; MultipleActiveResultSets=True;" />

效果很好。

我唯一能想到的就是我正在运行Windows 7Visual Studio 2017

我相信VS.NET 2017 可能会捆绑SQL Server 2016,我知道这与Windows 7 不兼容。

【讨论】:

  • 恭喜!但似乎这不是 localdb 的连接字符串..
  • 作为其他人的简单参考,我同时使用Windows7 Ultimate 64位和SQL Server 2016。
猜你喜欢
  • 2016-08-10
  • 2022-01-20
  • 1970-01-01
  • 1970-01-01
  • 2017-04-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多