Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
283 views
in Technique[技术] by (71.8m points)

asp.net - Server Error in '/' Application (error: 26 - Error Locating Server/Instance Specified) in Azure

I have a web application ASP.NET in VB.NET in Azure, which connects to a database. The database is also in Azure, in the same resource group.

But when my app tries to connect with the database, this error appears:

Server Error in '/' Application. 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: 26 - Error Locating Server/Instance Specified)

How do I configure my app in order to establish the connection with the database? Which is the correct connection string? Where do I have to paste it?

As you see, I'm a complete noob. Azure shows perfectly all the .aspx pages, and the database runs the querys fine. But it seems to be that I cannot establish the connection between the app and the database.

In the black square you can see where I get the connection string from. In the red square you can see the connection string I copied and pasted in the web.config file and in the vb code of my app. But it still doesn't work:

connection string

I also added a new connection string in my app, setting the connection string I got as the value:

connection string 1

Thanks in advance for your help.

question from:https://stackoverflow.com/questions/65924201/server-error-in-application-error-26-error-locating-server-instance-spec

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For anyone having my same problem, I've found the solution.

The problem was that my vb code had the connection string. So, it was useless to change the connection string only in the web.config file.

So, in my vb code I wrote a reference to my connection string, via the name of it.

Then, when the app was in Azure, I changed the connection string in the web.config.

And it worked ;)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...