Y Yoldi Member Apr 23, 2020 #1 Hi. I need to connect to a Sql server that has a linked server where is the table I need. it is possible to do it with b4j the driver net.sourceforge.jtds.jdbc.Driver and the jdbcsql library. Does anyone have a connection example? Thanks in advance
Hi. I need to connect to a Sql server that has a linked server where is the table I need. it is possible to do it with b4j the driver net.sourceforge.jtds.jdbc.Driver and the jdbcsql library. Does anyone have a connection example? Thanks in advance
Erel B4X founder Staff member Licensed User Longtime User Apr 24, 2020 #2 Are you able to connect to a database on that server, not on the linked server? Upvote 0
Y Yoldi Member Apr 24, 2020 #3 Hi. to a server database if I can but not to the link server database. Upvote 0
Jorge M A Well-Known Member Licensed User Longtime User Apr 25, 2020 #4 Yoldi said: not to the link server database. Click to expand... You don't need to do anything to connect to the " linked server". Once connected to your main server (I guess that's why Erel's ask you), assuming everything is correctly configured on your server, what you must change are your queries, with OPENQUERY, indicating the name of the linked server and your query sentence. Code: Copy Dim RS As ResultSet = SQL.ExecQuery("SELECT * FROM OPENQUERY([linkedServerName], 'SELECT * FROM {linkedDB}.{schema}.{table}')") --eg: Dim RS As ResultSet = SQL.ExecQuery("SELECT * FROM OPENQUERY([toshiba], 'SELECT Name FROM Sales.dbo.Customer')") Upvote 0
Yoldi said: not to the link server database. Click to expand... You don't need to do anything to connect to the " linked server". Once connected to your main server (I guess that's why Erel's ask you), assuming everything is correctly configured on your server, what you must change are your queries, with OPENQUERY, indicating the name of the linked server and your query sentence. Code: Copy Dim RS As ResultSet = SQL.ExecQuery("SELECT * FROM OPENQUERY([linkedServerName], 'SELECT * FROM {linkedDB}.{schema}.{table}')") --eg: Dim RS As ResultSet = SQL.ExecQuery("SELECT * FROM OPENQUERY([toshiba], 'SELECT Name FROM Sales.dbo.Customer')")