FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour adodb one or more connection
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
adodb one or more connection
Posted: Fri Feb 17, 2023 04:17 PM

Hi,

Can I to have two adodb connections at the same time on different databases?

I have two servers and I'd like to open one connection tu DB2 and another to SQL Server.

thank you

Damiano.

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: adodb one or more connection
Posted: Sat Feb 18, 2023 11:27 AM

Yes, what's the problem?

Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: adodb one or more connection
Posted: Sat Feb 18, 2023 06:54 PM

Damiano:

Why not?

Regards

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: adodb one or more connection
Posted: Wed Feb 22, 2023 07:52 AM
I open the first connection (DB2):
pgm1.prg
Code (fw): Select all Collapse
Connessione := "Provider=IBMDA400; Data Source=192.168.1.1; User Id=userid; Password=password; Default Collection=Library;"
oCn := FW_OpenAdoConnection( Connessione, .t.)
DB2 connection remains open for the duration of the program.

I open the second connection (SQl Server):
pgm2.prg
Code (fw): Select all Collapse
cConnSrv := "Provider=SQLOLEDB;server=192.168.1.2\SQLSERVER;database=MYDB;uid=sa;pwd=sa"
oCnSrv := FW_OpenAdoConnection( cConnSrv, .t.)
...
...
tuple := "SELECT A, B FROM SQLTABLE "
oDbo := FW_OpenRecordSet( oCnSrv, tuple, 1 )    
xbrowse(oDbo)
oDbo:Close()
oCnSrv:Close()
Return NIL
then reopen the pgm2.prg (SQL SERVER) and to istruction
Code (fw): Select all Collapse
oDbo := FW_OpenRecordSet( oCnSrv, tuple, 1 )
I Get that error: IBMDA400 is it's already open (the first connection).

in adofuncs.pgm if I comment out the lines 91-94 and 100-103 the pgm works without errors
Code (fw): Select all Collapse
91   if If( Empty( cSpec ), cConnStr == scStr1 .or. cConnStr == scStr2, cSpec == scSpec )
92     soCn_Check()
93     return soCn
94   endif
95
96  if ! Empty( cSpec )
97      cConnStr    := FW_AdoConnectionString( cConnStr, @nDB )
98   endif
99
100   if ( ! Empty( cSpec ) .and. cSpec == scSpec ) .or. cConnStr == scStr1 .or. cConnStr == scStr2
101     soCn_Check()
102     return soCn
103  endif
Why ?
FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: adodb one or more connection
Posted: Wed Feb 22, 2023 04:09 PM
Damiano:

Try with ReOpen
Code (fw): Select all Collapse
FW_ReOpenRecordSet(oDbo,oCnSrv, tuple, 1 )
Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: adodb one or more connection
Posted: Thu Feb 23, 2023 07:41 AM

hi Armando,

FW_ReOpenRecordSet is there in FWH 17.09 ?

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: adodb one or more connection
Posted: Thu Feb 23, 2023 07:32 PM
Damiano:

If you have FW_OpenRecordSet( oCnSrv, tuple, 1 ), I think yes, you have
the FW_ReOpenRecordSet() function too.

Pls try it


If there is not the FW_ReOpenRecordSet() function, you can try with this code
Code (fw): Select all Collapse
   IF oDbo <> NIL
      IF oDbo:State() = adStateOpen
         oDbo:Close()
      ENDIF
   ENDIF

   oDbo := FW_OpenRecordSet( oCnSrv, tuple, 1 )

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero

Continue the discussion