Live Server - A network-related or instance-specific error - connection-string

My site's login / membership doesn't work on the live server, when hosted. I get this infamous error:
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)
My connection string is as follows:
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
What am I doing wrong?
Thanks for any help.

you need check TCP/IP properties
in sql server configuration

Related

I am unable to connect to my Azure SQL Database from my website however I can connect to it with SSMS

I get this error:
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)
My connection string:
<add name="fxnzConnectionString"
connectionString="Server=tcp:fxnz.database.windows.net,1433;Initial Catalog=fxnz;Persist Security Info=True;User ID=xxxxxxxx;Password=vvvvvvvvv"
providerName="System.Data.SqlClient"/>
You need to grant Azure services access to your database.
Locate your server.
Click on "Show firewall settings"
Set "Allow Azure services and resources to access this server" to ON.

added migration , but database is not created

migration is added and the connection string is correct but the database is not created
what should i do
help me please
i closed the sql server and re-opened it but nothing is changed
my connection string :
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.;
Initial Catalog=Final_BD;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
http://i.stack.imgur.com/SR3Qf.png
when i try updata-database it shows me an error message :
" 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) "
http://i.stack.imgur.com/9oQOR.png
Try changing your connection string as:
"Data Source=.\SQLSERVER;
Initial Catalog=Final_BD;Integrated Security=True"
providerName="System.Data.SqlClient"
when i try updata-database it shows me an error message :
" 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) "
http://i.stack.imgur.com/9oQOR.png

A network-related or instance-specific error occurred while establishing a connection to SQL Server. No SQL Express on server manager

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)
Anyone can help me with this? I am using SQL Management Studio 2012. I already tried opening sql server manager but I dont see any SQLEXPRESS server in there. Im just using localdb. Sorry guys im just a newbie in web development.
This is my connection string
add name="MyCon2"
connectionString="Server=Villar-PC\Justin;Database=DBNAME; Integrated Security=true;>
Run services.msc and check sql server (or express depending on what you have) service. It should be running. If not, start it and check.
Also check if the database you are mentioning exists
Edit: If you are using sql localdb, you can refer to http://www.asp.net/mvc/overview/getting-started/introduction/creating-a-connection-string for the connection string
<add name="MovieDBContext"
connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Movies.mdf;Integrated Security=True"
providerName="System.Data.SqlClient"
/>

Connect to external SQL Server through Entity Framework

Basically I need to test a database on an external server (the model matches the model of my local test database).
Here is the connection string I have so far:
<connectionStrings>
<add name="DefaultConnection"
connectionString="Database=QualityLinkBuilder;Server=12.345.678.901.\SQLExpress;uid=RemotePc\Administrator;pwd=MyPassword;"
providerName="System.Data.SqlClient" />
</connectionStrings>
When I attempt to connect now I get the generic error:
The underlying provider failed on Open.
Inner exception message:
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)
It should be just Server=12.345.678.901\SQLExpress in your connection string ( replace "\SQLExpress" with the relevant SQL Server instance name on the external server )

Error when trying to establish a MVC connection to SQL Server 2012 (localdb) running on my PC

I have set up my web.config like this:
<add name="DefaultConnection" connectionString="Data Source='C:\Users\Marilou\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\v11.0\authentication.mdf';Initial Catalog=javacert;Persist Security Info=True;User ID=sa;Password=yyy" providerName="System.Data.SqlClient" />
But I am getting the message:
Message=The provider did not return a ProviderManifestToken string.
Source=EntityFramework
StackTrace:
at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)
InnerException: System.Data.SqlClient.SqlException
HResult=-2146232060
Message=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)
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Seems like you are using LocalDB. From this MSDN article (http://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx), the connection string is as follows :
Data Source=(localdb)\v11.0;Integrated Security=true;AttachDbFileName=C:\MyData\Database1.mdf".

Resources