使用SQL Alias问题连接到SQL Server

时间:2022-01-30 01:40:44

I created an SQL Alias:

我创建了一个SQL别名:

Name: CIHDB
Server: SQLSRV
Protocol: tcp
Port no: (empty)

My connection string within Visual Studio says:

我在Visual Studio中的连接字符串说:

Data Source=CIHDB;Initial Catalog=CIH;Integrated Security=SSPI;MultipleActiveResultSets=True;Application Name=EntityFramework

Data Source = CIHDB; Initial Catalog = CIH; Integrated Security = SSPI; MultipleActiveResultSets = True; Application Name = EntityFramework

But that fails with the error: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.

但是由于错误而失败:TCP提供程序,错误:0 - 无法建立连接,因为目标计算机主动拒绝它。

When I change the "Data Source" in the connection string to "localhost," I connect with no problem.

当我将连接字符串中的“数据源”更改为“localhost”时,我连接没有问题。

I am thinking that I am using the wrong protocol in the Alias.

我在想我在Alias中使用了错误的协议。

Can anybody shed some light on this?

任何人都可以对此有所了解吗?

Thanks Eric

1 个解决方案

#1


3  

When I used both

我两个都用的时候

cliconfg.exe

and

c:\windows\syswow64\cliconfg.exe

(64 and 32 bit versions of cliconfg.exe)

(64位和32位版本的cliconfg.exe)

I saw that tcp/ip was not enabled and so once I fixed that, all fell into place.

我看到tcp / ip没有启用,所以一旦我解决了,所有都落到了位置。

#1


3  

When I used both

我两个都用的时候

cliconfg.exe

and

c:\windows\syswow64\cliconfg.exe

(64 and 32 bit versions of cliconfg.exe)

(64位和32位版本的cliconfg.exe)

I saw that tcp/ip was not enabled and so once I fixed that, all fell into place.

我看到tcp / ip没有启用,所以一旦我解决了,所有都落到了位置。