System.data.sqlclient.sqlexception (0x80131904): связанная с сетью или
exature-scific-secific при установлении соединения с
sql server. Сервер не был найден или не был доступен. Убедитесь
, что имя экземпляра верно и и SQL Server настроен
, чтобы разрешить удаленные подключения. (provider: Named P ipes Provider, error:
40 - Could not open a connection to SQL Server) ---> Syste
m.ComponentModel.Win32Exception (0x80004005): Access is denied at
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdent
ity identity, SQLConnectionString ConnectionOptions, SQLCredential
Coldential, O Bject ProviderInfo, String NewPassword, Securestring
NewsecurePassword, Boolean RedirectedUserinStance, SQLConnectionString
userconnectionoptionop, SessionData, eConnectDate,
dbconnectionoptiono Boolean Applytra
nsientfaulthandling, sqlauthentication providermanager
sqlauthprovidermanager) на
system.data.sqlclient.sqlConnectionFactory.createConnection (dbConnectionop
yons options, dbconnectionpoolkey, poolkey, obhound
yons, dbconnectionpoolkeypoolkekey, ObjecteCongep Poolgroupproviderinfo, Dbconn ectionPool Pool, DBConnection
heliveConnection, dbconnectionoptions userptions) < /p>
at
system.data.providerbase.dbconnectionfactory.createpooledConection (dbconnection. helowingObject, dbconnectionoptions , dbconne ctionpoolkey poolkey, dbconnectionoptions
userptions) at
system.data.providerbase.dbconnectionpool.createobject (dbconnection
helive oversection ortemptionnection
ordation oldectionnectioninectioninectioninenection
dbconnectionoptions. at
system.data.providerbase.dbconnectionpool.usercreaterequest (dbconnection
o wningobject, dbconnectionoption ningObject, UInt32 waitForMultipleObjectsTimeout, Boolean
allowCreate, Boolean o nlyOneCheckConnection, DbConnectionOptions
userOptions, DbConnectionInternal& co nnection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
ow ningobject, taskCompletionsource1 retry, DbConnectionOptions
userOptions, DbCon nectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource< /code> 1 повторить, dbconnectionoptions
userptions, dbconnectioninternal oldconnection,
dbconnectioninternal & connection) at
system.data.providerbase.dbconnectioninternal.tryopenconnectionintaler (db
connection outerconection, dbonnectory, dbonnectory, dbonnectory, dbonnectory, dbonnectory, dbonnectory, dbonnectory. TaskCompletio nsource1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource< /code> 1 повторение, dbconnectionoptions userptions) at
system.data.sqlclient.sqlconnection.tryopeninner (taskCompletionionSource1
re try) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource< /code> 1
retry) at system.data.sqlclient.sqlconnection.open () at
yetanothersmallconsoleapp.program.main (string [] args) в
c: \ repository \ pro
jects \ iltanotherconsoleapp \ 28 ClientConnectionId: 00000000-0000-0000-0000-000000000000 < /p>
< /blockquote>
Вот моя программа: < /p>
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.IO;
namespace YetAnotherSmallConsoleApp
{
class Program
{
static void Main(string[] args)
{
SqlConnection con = new SqlConnection("Server = IP_ADDRESS; User Id = USER_NAME; Password = PASSWORD;");
string[] arrExcludeLines = File.ReadAllLines(FILEPATH_TO_QUERY);
string strExcludeQuery = default(string);
foreach (string line in arrExcludeLines)
{
strExcludeQuery = strExcludeQuery + line + Environment.NewLine;
}
try
{
using (con)
{
con.Open();
SqlCommand cmdExclude = new SqlCommand(strExcludeQuery, con);
SqlDataReader dr1 = cmdExclude.ExecuteReader();
while (dr1.HasRows)
{
while (dr1.Read())
{
Console.WriteLine(dr1[0].ToString());
Console.ReadLine();
}
dr1.NextResult();
}
}
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
Console.ReadLine();
}
}
}
}
< /code>
Ошибка выбрасывается из строки, которая считывает con.open (); < /code>. Вот несколько фактов о серверах: < /p>
- Оба сервера A и сервер B находятся в одной и той же сети, и эта сеть не является
та же сеть My MS SQL Server 2016. Это. < /li>
Несмотря на то, что моя программа правильно работает на сервере A I не могу пинговать IP -адрес
сервер базы данных MS SQL Server 2016 с любого сервера A Net Server B. < /li>
На сервере MS -сервер a или сервера B. < /li>
. />
Изменить: когда я пытаюсь подключиться к базе данных MS SQL Server 2016 с сервера B, используя те же учетные данные, которые я использую для подключения к базе данных с сервера A, используя SSMS, я получаю следующую ошибку: < /p>

EDIT: one other thing: I've tried to run the program with the computer name for the MS SQL Server 2016 database server in the connection string as well as the actual IP address for the database server in the connection string, both ways result in being able to run the program successfully on Server A but I get the error на сервере b.
Подробнее здесь: https://stackoverflow.com/questions/535 ... 0x80131904