adodb one or more connection

adodb one or more connection

Postby damianodec » Fri Feb 17, 2023 4: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 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
 
Posts: 419
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia


Re: adodb one or more connection

Postby Armando » Sat Feb 18, 2023 6: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
User avatar
Armando
 
Posts: 3230
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: adodb one or more connection

Postby damianodec » Wed Feb 22, 2023 7:52 am

I open the first connection (DB2):
pgm1.prg
Code: Select all  Expand view  RUN
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: Select all  Expand view  RUN
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: Select all  Expand view  RUN
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: Select all  Expand view  RUN

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 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
 
Posts: 419
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia

Re: adodb one or more connection

Postby Armando » Wed Feb 22, 2023 4:09 pm

Damiano:

Try with ReOpen

Code: Select all  Expand view  RUN

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
User avatar
Armando
 
Posts: 3230
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: adodb one or more connection

Postby damianodec » Thu Feb 23, 2023 7:41 am

hi Armando,
FW_ReOpenRecordSet is there in FWH 17.09 ?
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
 
Posts: 419
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia

Re: adodb one or more connection

Postby Armando » Thu Feb 23, 2023 7: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: Select all  Expand view  RUN

   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
User avatar
Armando
 
Posts: 3230
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], wmormar and 91 guests