0
votes

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

5
Are you sure your PC's name is 'USER-PC'? - user2742438
Yes, because it works SQLEXPRESS.. - CodeXerox
Is SQL Server the name of the SQL Server instance? The instance name is configured when you install SQL Server. - FrankPl
@user2460637 the database I am using is compatible with SQL Server version not with Express. So, I have to use Sql Server. - CodeXerox
@FrankPl I have added image for that. As you can see it is SQL Server 10.50.1600 If the instance is Express then it should be SQLEXPRESS instead of SQL Server. - CodeXerox

5 Answers

0
votes

The following connection string should probably work:

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

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
0
votes

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 :)

0
votes

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

0
votes

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>