error connecting to sql server compact file in VS2012 - sql-server

I use following connection string for connecting to my SQL Server Compact database (.SDF file) in a VS 2012 (.NET 4) Win form app:
SqlConnection SQLConnection = new SqlConnection("Data Source=d:\\mydb.sdf;");
but I get following error, what is going wrong?
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)

Use SqlCeConnection instead of SqlConnection.

Related

SQL Server Express conection string

I'm trying to connect to a local SQL Server Express database using EF Core with this connection string:
"Server=(localdb)\\WIN-R84DEUE96RB\\SQLEXPRESS;Database=rmcsql;Trusted_Connection=True"
I get this error:
fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]
An error occurred using the connection to database 'rmcsql' on server '(localdb)\WIN-R84DEUE96RB\SQLEXPRESS'.
fail: Microsoft.EntityFrameworkCore.Query[10100]
An exception occurred while iterating over the results of a query for context type 'RMC_IEM.DataStore.EF.ApplicationDBContext'.
Microsoft.Data.SqlClient.SqlException (0x80131904): 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: SNI_PN11, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)
What is wrong with this connection string?

SQL Server Management Studio problem with connect

I've got problem with connecting SQL Server by SQL Server Management Studio. I installed the latest version. I want to connect by windows authentication. I tried server name like:
computer_name\SQLEXPRESS
localhost\SQLEXPRESS
127.0.0.1\SQLEXPRESS
But it still doesn't work. I'll be glad for any help with this.
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: SQL
Network Interfaces, error: 26 - Error Locating Server/Instance
Specified) (Microsoft SQL Server, Error: -1)

SQL Network Interfaces, error: 26

My Windows 10 pc installed an update overnight. Today I have this message (below) when I launch SQL Server 2014 and try to 'Connect to Server'. Any ideas as to what Microsoft may have done to me please? Thanks in advance!
**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) (Microsoft SQL Server, Error: -1)**

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"
/>

using sql server with vs 2012

Am facing a problem with using SQL server 2012 along with VS 2012 ,, when I try to make new database it gives me 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)”
I've tried to install the SQL Server Express 2012 again but still the same problem.
any suggestions ?
thanks in advance .
Most Probably you are something missing in ConnectionString, might be server name
open sql server and check server name.
working connectionString:

Resources