FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour connection two SQL server and two databases
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: connection two SQL server and two databases

Posted: Sat May 23, 2015 10:30 AM

Using linked servers is used when we want the link to last for the entire session. This was the only method long time back.

OPENROWSET can be used as part of the SQL statement to connect to a table on a different server and this can be any server (non mssql also) that can be connected though an OLEDB connection. Going through the documentation would help. This is the oft-used way.

Regards



G. N. Rao.

Hyderabad, India
Posts: 130
Joined: Sun Mar 08, 2009 04:33 PM

Re: connection two SQL server and two databases

Posted: Sun May 24, 2015 08:40 AM
Code (fw): Select all Collapse
EXEC sp_addlinkedserver 
   @server = N'Spedicija', 
   @srvproduct = N'',
   @provider = N'SQLNCLI', 
   @datasrc = N'192.168.150.2\SqlSmart';
GO
This works when I have a local server, and a remote server. But if we have two remote server (which is the actual situation) When I send a query
Code (fw): Select all Collapse
            nErr := oSqlSpe:exec("INSERT INTO &cKnjiga (GK_Godina, GK_Firma, GK_Nalog, GK_Datum, GK_Dokum, GK_Opis, GK_Konto, GK_Analit, GK_DugPoc, GK_PotPoc, GK_Duguje, GK_Potraz)"+;
                       " SELECT GK_Godina, '" + mFirma_id + "', GK_Nalog, GK_Datum, GK_Dokum, GK_Opis, GK_Konto, GK_Analit, GK_DugPoc, GK_PotPoc, GK_Duguje, GK_Potraz FROM [Sped].Infobit.dbo.Spe_knjiga"+;
                       " WHERE &cFirma .Gk_Godina= '" + mObrGod + "'")
I get an error message:
42000 - 27 - [Microsoft][SQL Server Native Client 10.0][SQL Server]Registry information is corrupt or missing. Make sure the provider installed and registered correctly.
Best regards

Milos



[ FWH 21.11 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603) ]
Posts: 130
Joined: Sun Mar 08, 2009 04:33 PM

Re: connection two SQL server and two databases

Posted: Sun May 24, 2015 08:47 AM
Executed on the local server (and the first remote server):

Code (fw): Select all Collapse
EXEC sp_addlinkedserver 
   @server = N'Spedicija', 
   @srvproduct = N'',
   @provider = N'SQLNCLI', 
   @datasrc = N'192.168.150.2\SqlSmart';
GO

This works when I have a local server, and a remote server. But if we have two remote server (which is the actual situation) When I send a query
Code (fw): Select all Collapse
   nErr := oSqlSpe:exec("INSERT INTO &cKnjiga (GK_Godina, GK_Firma, GK_Nalog, GK_Datum, GK_Dokum, GK_Opis, GK_Konto, GK_Analit, GK_DugPoc, GK_PotPoc, GK_Duguje, GK_Potraz)"+;
                       " SELECT GK_Godina, '" + mFirma_id + "', GK_Nalog, GK_Datum, GK_Dokum, GK_Opis, GK_Konto, GK_Analit, GK_DugPoc, GK_PotPoc, GK_Duguje, GK_Potraz FROM [Spedicija].Infobit.dbo.Spe_knjiga"+;
                       " WHERE &cFirma .Gk_Godina= '" + mObrGod + "'")

I get an error message:
42000 - 27 - [Microsoft][SQL Server Native Client 10.0][SQL Server]Registry information is corrupt or missing. Make sure the provider installed and registered correctly.

Regards,
Milos
Best regards

Milos



[ FWH 21.11 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603) ]
Posts: 130
Joined: Sun Mar 08, 2009 04:33 PM

Re: connection two SQL server and two databases

Posted: Sat Jul 11, 2015 10:25 AM
Hi,

Please, there is someone who can help me? I have new error:

Error SR_ODBC/0 SQLExecDirect Error
42000 - 65535 - [Microsoft][SQL Server Native Client 10.0][SQL Server]SQL Server Network Interfaces: Error getting enabled protocols list from registry [xFFFFFFFF].


Regards
Milos
Best regards

Milos



[ FWH 21.11 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603) ]

Continue the discussion