connection two SQL server and two databases

Re: connection two SQL server and two databases

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10642
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: connection two SQL server and two databases

Postby mtajkov » Sun May 24, 2015 8:40 am

Code: Select all  Expand view
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: Select all  Expand view
            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) ]
mtajkov
 
Posts: 130
Joined: Sun Mar 08, 2009 4:33 pm

Re: connection two SQL server and two databases

Postby mtajkov » Sun May 24, 2015 8:47 am

Executed on the local server (and the first remote server):

Code: Select all  Expand view
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: Select all  Expand view

   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) ]
mtajkov
 
Posts: 130
Joined: Sun Mar 08, 2009 4:33 pm

Re: connection two SQL server and two databases

Postby mtajkov » 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) ]
mtajkov
 
Posts: 130
Joined: Sun Mar 08, 2009 4:33 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 56 guests