简体   繁体   English

Azure-将.NET Web应用程序与Azure SQL数据库连接

[英]Azure - Connecting .NET web app with azure sql database

I have a team project and I'm trying to publish the app at Azure, which I successfully did. 我有一个团队项目,我正在尝试在Azure上发布该应用程序,而我成功做到了。 I was able to get our database to Azure SQL server, but now I'm struggling with connecting the app with this database. 我能够将数据库连接到Azure SQL服务器,但是现在我正在努力将应用程序与此数据库连接。

Originaly the app is working with a .mdf file locally, but now, when I'm publishing the app, I want to use the DB at azure server. 最初,该应用程序在本地使用.mdf文件,但是现在,当我发布该应用程序时,我想在azure服务器上使用该数据库。 I changed all the connection strings of .mdf file 我更改了.mdf文件的所有连接字符串

(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename =" + Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\PATH")) 

in the code to the azure database connection string 代码中的Azure数据库连接字符串

(@"Data Source = Server=tcp:nameofserver.database.windows.net,1433;Initial Catalog=sqlmusicdb;Persist Security Info=False;User ID=...;Password=...;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;")

but after publishing, the app is not connected to database, as it is writing 但是发布后,该应用程序在编写时未连接到数据库

AN ERROR OCCURRED WHILE PROCESSING YOUR REQUEST 处理您的请求时发生错误

Any help, please? 有什么帮助吗? Thanx. 谢谢

Your connection string is formatted incorrectly. 您的连接字符串格式错误。 Remove the 去除

Data Source = 资料来源=

at the very beginning of your connection string and it should work. 在连接字符串的开头,它应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM