I have connection string, but it isn't working. Why?
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)
Connection string:
<add name="CompanyEventConnectionString"
connectionString="database=db;server=PETLITSKY-R\SQLEXP;user id=sas; password=P#ssword1; MultipleActiveResultSets=True;" />
In the SQL Server Configuration Manager->SQL Server Network Configuration->Protocols, check that named pipes and tcp/ip are enabled.
If that doesn't work then it may be your firewall blocking it, try this link: http://msdn.microsoft.com/en-us/library/cc646023.aspx
This may be useful too: http://support.microsoft.com/kb/287932
<add name="ConString" connectionString="Data Source=.;InitialCatalog=ServerMaintenance;User Id=sa;Password=something;" />
Related
I am getting below error when i update database:
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: 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.
My Connection string section
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-Publicspeaking-20171215094113.mdf;Initial Catalog=aspnet-Publicspeaking-20171215094113;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
My SQL server Log In:
Server Name: LAPTOP-UH0CMBJT
User Name: LAPTOP-UH0CMBJT\waqas
I have added a database file (NORTHWND.MDF) to my application using Visual Studio 2010 built-in functionality. Database is in the App_Data folder.
It is running fine in local-host. But when I publish it and upload it to server it gives 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 is that automatically generated by visual studio in my web.config:
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\NORTHWND.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
My host support SQL Express, but it dont work..
I read that once everything is upped on the host do not have to use "AttachDbFilename" .. but I have not figured out how to fix it .. Could someone tell me the correct connection string?
Thanks in advance.
You Sholud Use this connection String if you have your db attached to SQL management Studio
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
User ID=myDomain\myUsername;Password=myPassword;
Reference:
https://www.connectionstrings.com/sql-server/
I have installed SQL Server 2012 Express on a Windows Server 2008 Machine. The name of the machine is "THEMACHINE". While installation, I set SQL Server 2012 as "Default Instance".
Now I set my connection string like this :
<add name="BooksContext" providerName="System.Data.SqlClient" connectionString="Data Source=THEMACHINE;Initial Catalog=newdb; User ID=sa; Password=123456"/>
But I get this exception :
{"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)"}
I checked that database is running. Can you tell me what I'm doing wrong?Thanks.
Reference: Creating and Configuring Universal Data Link (.udl) Files
Do following to Test connection and generate connection string,
1) Create query.udl file in the desktop
2) Double click the file to open and do the following
3)Open the Query.udl in notepad, you will find the connectionstring.
Change Data Source=THEMACHINE to Data Source=THEMACHINE\SQLEXPRESS. Also check that the database service is running.
I keep getting this error when I try to do an update-database command in the package manager console:
ClientConnectionId:00000000-0000-0000-0000-000000000000
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. Specified LocalDB instance name is invalid.
)
My connection string is:
<connectionStrings>
<add name="BookServiceContext" connectionString="Data Source=(localdb)\\v11.0; Initial Catalog=BookServiceContext-20150228232739; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|BookServiceContext-20150228232739.mdf" providerName="System.Data.SqlClient" />
</connectionStrings>
I can connect via SSMS 2014 and I can see (localdb)\MSSQLLocalDB and (localdb)\ProjectsV12 in the SQL Server Object Explorer.
EDIT
Even when a part of connection string is changed to:
AttachDbFilename=|DataDirectory|\BookServiceContext-20150228232739.mdf"
It still pulls the same error.
There is a backslash missing in you connection string:
instead of
AttachDbFilename=|DataDirectory|BookServiceContext-20150228232739.mdf"
it should be
AttachDbFilename=|DataDirectory|\BookServiceContext-20150228232739.mdf"
Refer to Creating a Connection String and Working with SQL Server LocalDB
Update
It turns out that after a \ wasn't missing but there are too many of them. I was able to reproduce the error by adding another \ to
Data Source=(localdb)\\v11.0
this means your Data Source should be:
Data Source=(localdb)\v11.0
with only one \
Kindly check your connection string
Data Source=(localdb)\ProjectsV13;Initial Catalog=master;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False
I have to establish a connection using connection string to DB.
I am using SQL Server 2008 R2, for which i need connection string.
It is not SQLEXPRESS.
Current String:
<connectionStrings>
<add name="ApplicationServices"
connectionString="server=USER-PC\SQL Server;database=TLE;Connection Timeout=40"
providerName="System.Data.SqlClient"/>
</connectionStrings>
But it is not working. I am getting 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)
The following connection string should probably work:
connectionString=
"server=USER-PC;Integrated Security=True;Initial Catalog=TLE;Connection Timeout=40;providerName=System.Data.SqlClient"
The connection string needs to include security information as well as the server.
Try
server=USER-PC;database=TLE;Connection Timeout=40;Trusted Connection=Yes
or
server=USER-PC;database=TLE;Connection Timeout=40;User ID=sqllogin;Password=something
Step 1: create a text file and save it as "abc.udl"
Step 2: Open that abc.udl file as OLE DB Core serices.
Step 3: Choose your provider. In this case it may be "sql server Native Client..."
Step 4: In connection tab fill your server information. And Test the connection.
Step 5: If it successful the again open "abc.udl" in the nodepad
Step 6: You will get your connection string.
Step 7: Remove unnecessary things like Provider,Initial File Name,Server SPN etc.
Try this connection string :)
Identify the sql server instance name. While installing SQL Server Express, you might have installed it under the default instance name (SQLEXPRESS). In that case you should use USER-PC\SQLEXPRESS
If you have not given the instance name and still you are unable to connect then try to give the IP address like this:
connectionString=
"server=Your_system_ip_address;Integrated Security=True;Initial Catalog=TLE;Connection Timeout=40;providerName=System.Data.SqlClient"
For more information regarding connection strings refer to this
Below worked for me fine.. Its for SQL Server not for SQLExpress..
<connectionStrings>
<add name="ApplicationServices"
connectionString="server=USER-PC;database=LTS;Integrated Security=True;Connection Timeout=40"
providerName="System.Data.SqlClient"/>
</connectionStrings>