Question

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)

Database Listing in SSMS 2008

Was it helpful?

Solution

The following connection string should probably work:

connectionString=
"server=USER-PC;Integrated Security=True;Initial Catalog=TLE;Connection Timeout=40;providerName=System.Data.SqlClient"

OTHER TIPS

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top