I use SQLRDD and ODBC connection for MYSql. How I open One table from one sql server and at the same time Open second table from second server?
Regards,
Milos
FWHX 12.08
cDatabase=AllTrim(System->Database)
If ! cDatabase IN hIniFile
MsgInfo("Connection [" + cDatabase + "] not found in sqlrdd.ini")
Quit
EndIf
hDsn := hIniFile[ cDatabase ]
If !"CONNSTRING" IN hDsn
MsgInfo( "ConnString not found in " + cDatabase)
Quit
EndIf
aDsn := OdbcDsnEntries()
if len(aDsn) == 0
MsgAlert("Mora te kreirati ODBC DSN konfiguraciju iz vašeg kontrol panela",;
"ODBC DSN selekcija")
return nil
endif
cConnString := hDsn[ "CONNSTRING" ]
if !Connect(cConnString)
return
endif
oSql := SR_GetConnection()
USE System NEW
hIniFile := HB_ReadIni( "sperdd.ini", .F.,,.F. ) // Read ini file in a hash table
sDatabase=AllTrim(System->Database)
If ! sDatabase IN hIniFile
MsgInfo("Connection [" + sDatabase + "] not found in sperdd.ini")
Quit
EndIf
hDsn := hIniFile[ sDatabase ]
If !"CONNSTRING" IN hDsn
MsgInfo( "ConnString not found in " + sDatabase)
Quit
EndIf
aDsn := OdbcDsnEntries()
if len(aDsn) == 0
MsgAlert("Mora te kreirati ODBC DSN konfiguraciju iz vašeg kontrol panela",;
"ODBC DSN selekcija")
return nil
endif
cConnString := hDsn[ "CONNSTRING" ]
if !Connect(cConnString)
return
endif
oSqlSpe := SR_GetConnection()
nErr := oSql: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 Infobit@Server:Spe_Knjiga"+;
" WHERE &cFirma .Gk_Godina= '" + mObrGod + "'")
First thing I want to tell you is that in T-SQL ( Transact SQL of MS Server ), all variables are prefixed with "@".
@Server means it is a variable by name "@Server".
We should not leave any variable name as it is in an Sql statement All should be constants.
If "infobit" is the server name, then Infobit must be substituted in the place of variable "@Server"
Instead of
Infobit@Server:Spe_Knjiga
It should be Infobit.Spe_knjiga
( full syntax is <Server>.<schema>.<tablename>)
For linked servers to work
we should link the server first by executing
sp_addlinkedserver(...)
EXEC sp_addlinkedserver
@server = N'Spedicija',
@srvproduct = N'',
@provider = N'SQLNCLI',
@datasrc = N'192.168.150.2\SqlSmart';
GO
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 89 guests