0

i am creating an asp.net web application. i am using SQL server 2014 for database. i need configure a connection string on client computer web form project to access SQL server data on an other computer through query using asp.net c#. i disabled all firewalls on the host computer and also on client computer, enabled tcp/ip port setting, and enter the following connection string in client computer web configuration" this is the host server name"DESKTOP-H8JV03C" and prot is"1433"; but on ruining the query the browser give me the following error 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)

<add name="nadra" 
     connectionString ="Data Source=DESKTOP-H8JV03C,1433;Initial Catalog=Nadra;Trusted_Connection=True;Integrated Security=True" 
       providerName="System.Data.SqlClient"/> 
Aristos
  • 66,005
  • 16
  • 114
  • 150
parii
  • 1
  • 3
  • Does the user running the code have access to the PC you are trying to access? – Brad Nov 30 '18 at 14:41
  • Make sure you can ping the other PC using its machine name. This is a connectivity issue and has nothing to do with programming and is therefore off-topic. – fourwhey Nov 30 '18 at 14:43
  • what is your connection string ? – Aristos Nov 30 '18 at 15:33
  • this is connection string – parii Nov 30 '18 at 15:45
  • please can you tell me the ping method ! – parii Nov 30 '18 at 15:47
  • @parii - it's just "ping", so e.g. `ping desktop-h8jv03c` in a command-prompt. That will only tell you basic connectivity though. Next run PowerShell (on the Windows menu) and run `New-Object System.Net.Sockets.TcpClient("desktop-h8jv03c", 1433)`. It it returns quickly and "Connected" is True, then the network isn't an issue, and more likely Windows permissions is. If false, it's network at least, might be permissions next. – sellotape Nov 30 '18 at 16:06
  • @parii Press `Win+R` Open a command prompt window by type `cmd` then type `ping desktop-h8jv03c` – Aristos Nov 30 '18 at 16:15

1 Answers1

0

Integrated Security=True on your string means that its try to connect to the other server with the credential that asp.net pool have on the local computer.

If they are not match, probably not, then you need either make the same user on both computers with the same password that runs the pool, also have credential to runs on SQL Server , but better use a connection string that connects with the correct user id and pass of sql server on the remote computer.

something like:

<add name="nadra" 
     connectionString ="Data Source=DESKTOP-H8JV03C,1433;Initial Catalog=Nadra;Trusted_Connection=True;User ID=UserName;Password=Password" 
       providerName="System.Data.SqlClient"/> 
Aristos
  • 66,005
  • 16
  • 114
  • 150