从网络核心应用程序连接到链接数据库

时间:2022-03-01 02:59:11

I'm trying to connect to a linked server from .net core. I connect to my SQL Server, but I cannot reach the Oracle Database linked on it.

我正在尝试从.net核心连接到链接服务器。我连接到我的SQL Server,但我无法访问链接到它的Oracle数据库。

For example, I can connect to an actual SQL Server Database with the cnnStr:

例如,我可以使用cnnStr连接到实际的SQL Server数据库:

"Server=foo\SQLEXPRESS;Database=DatabaseName;Trusted_Connection=True;MultipleActiveResultSets=true"

“服务器= FOO \ SQLEXPRESS;数据库=数据库名; Trusted_Connection = TRUE; MultipleActiveResultSets =真”

But if I change the Database parameter to the linked server, I get an error "Cannot open database "dbLINK" requested by the login. The login failed"

但是如果我将Database参数更改为链接服务器,则会收到登录请求的“无法打开数据库”dbLINK错误。登录失败“

Does anyone knows how to connect to a linked database? Thanks in advance

有谁知道如何连接到链接数据库?提前致谢

1 个解决方案

#1


1  

I believe the right way to do that is either creating views that access your linked server or access your linked server data directly from your query, for example, SELECT * FROM OPENQUERY([LINKEDSERVERNAME], 'SELECT Id, Name, Age from USER');

我认为正确的方法是创建访问链接服务器的视图或直接从查询访问链接的服务器数据,例如,SELECT * FROM OPENQUERY([LINKEDSERVERNAME],'SELECT Id,Name,来自USER的年龄' );

It`s important to point out that views are probably gonna be a better practice in this case. If you change anything related to your linked server in the near future, you'll need to change things in only one place.

重要的是要指出,在这种情况下,观点可能会更好。如果您在不久的将来更改与链接服务器相关的任何内容,则只需要在一个位置更改内容。

#1


1  

I believe the right way to do that is either creating views that access your linked server or access your linked server data directly from your query, for example, SELECT * FROM OPENQUERY([LINKEDSERVERNAME], 'SELECT Id, Name, Age from USER');

我认为正确的方法是创建访问链接服务器的视图或直接从查询访问链接的服务器数据,例如,SELECT * FROM OPENQUERY([LINKEDSERVERNAME],'SELECT Id,Name,来自USER的年龄' );

It`s important to point out that views are probably gonna be a better practice in this case. If you change anything related to your linked server in the near future, you'll need to change things in only one place.

重要的是要指出,在这种情况下,观点可能会更好。如果您在不久的将来更改与链接服务器相关的任何内容,则只需要在一个位置更改内容。