从UNC路径运行时无法连接到SQL

时间:2017-04-12 16:51:57

标签: c# sql-server

在本地运行时工作正常。但是从UNC路径运行时(仍然在同一台物理机器上运行)。也适用于其他SQL服务器...只是这一个(它是一个命名实例/不同的端口,但我尝试使用ip,port; hostname \ instance; hostname \ instance,port; hostname,端口和连接字符串的各种派生,仍然没有快乐;

<add key="onnString" value="Data Source=10.121.45.201,14332;Initial Catalog=FACEDB;Integrated Security=SSPI;"/>

string comm = "SELECT * FROM PAYMENTS WHERE CODE = '" + org_code + "'";
        SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["onnString"]);
        DataSet ds = new DataSet();
        SqlDataAdapter adapter = new SqlDataAdapter(comm, conn);
        adapter.SelectCommand.CommandTimeout = 120;
        short retries = 0;
        while (true)
        {
            try
            {
                adapter.Fill(ds);
                break;
            }
            catch (Exception ex)
            {

错误;

Message "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: TCP Provider, error: 0 - An invalid argument was supplied.)"   string

有什么好主意吗?

帐户肯定有权访问(我可以通过ssms连接)

0 个答案:

没有答案