FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Problems with an application using ADO
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Problems with an application using ADO
Posted: Sat Jun 08, 2013 01:44 PM
Antonio

Here is how I create an Ado recordset on demand ..

Rick Lipkin

Code (fw): Select all Collapse
Func Main()

Local cFile,aDir,nStart,cDefa,xProvider,xSource
Public xDatabase,xConnect

/-- get timestamp on .exe //

cFILE := GetModuleFileName( GetInstance() )
aDIR  := DIRECTORY( cFILE )

// where .exe started from is default directory //

nSTART := RAT( "\", cFILE )
cDEFA  := SUBSTR(cFILE,1,nSTART-1)

aDIR   := NIL

SET DEFA to ( cDEFA )


xDATABASE := "A"      // access
// xDATABASE := "S"   // sql server
// xCATALOG  := "SERVICE"
// xUSERID   := "serviceuser"

xPROVIDER := "Microsoft.Jet.OLEDB.4.0"
xSOURCE   := cDEFA+"\Groom.mdb"
xPASSWORD := "password"

IF xDATABASE = "A"
   xCONNECT := 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Jet OLEDB:Database Password='+xPASSWORD
ELSE
   xCONNECT := 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xCATALOG+';User Id='+xUSERID+';Password='+xPASSWORD
ENDIF

REQUEST DBFCDX
rddsetdefault ( "DBFCDX" )

...
...

// open a recordset on demand with sql statement and connection string

oRsUser := TOleAuto():New( "ADODB.Recordset" )
oRsUser:CursorType     := 1        // opendkeyset
oRsUser:CursorLocation := 3        // local cache
oRsUser:LockType       := 3        // lockoportunistic

cSQL := "SELECT * From [Staff] Order by [Lname]"

TRY
  oRsUser:Open(cSQL,xCONNECT )
CATCH oErr
  MsgInfo( "Error in Opening Staff table" )
  RETURN(.F.)
END TRY

xbrowse( oRsUser )
oRsUser:CLose()
oRsUser := nil
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Problems with an application using ADO
Posted: Sat Jun 08, 2013 07:05 PM
Enrico,


Also Rick suggestion for not having opened connections seems very interesting.

I already use that.


Would you mind to post an example of how you do it ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Problems with an application using ADO
Posted: Sat Jun 08, 2013 07:27 PM

Antonio

Notice in my post the variable xConnect .. just a connection string .. Pass that to oRsUser:Open(cSQL,xCONNECT ) and you have a fetch of rows on demand .. no need to create and pass an ( active ) connection.

Rick Lipkin
ps .. Enrico shared this ( type of ) example with me several years ago when I was just a 'padawan learner' struggling with ADO :D

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Problems with an application using ADO
Posted: Sat Jun 08, 2013 07:39 PM
Antonio,

Antonio Linares wrote:Enrico,


Also Rick suggestion for not having opened connections seems very interesting.

I already use that.


Would you mind to post an example of how you do it ? thanks


As for Rick sample. :-)

EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Problems with an application using ADO
Posted: Sat Jun 08, 2013 08:54 PM

Enrico,

ok, I missed it, thanks! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM
Re: Problems with an application using ADO
Posted: Mon Jun 10, 2013 05:34 PM

Enrico,

Any news?.

Thank you.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Problems with an application using ADO
Posted: Mon Jun 10, 2013 05:36 PM
Elvira and Antonio,

elvira wrote:Enrico,

Any news?.

Thank you.


It seems that the problem started after the installation of FWH 13.04.

Any ideas?

EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Problems with an application using ADO
Posted: Mon Jun 10, 2013 05:42 PM

I just get the notice from my client that the problem is not with ADO but with DBF also. :-(

EMG

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Problems with an application using ADO
Posted: Mon Jun 10, 2013 05:51 PM

Probably it means nothing for this problem but in tmsgitem.prg there are two different definition for the method Refresh.

Antonio, can you check it, please?

EMG

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Problems with an application using ADO
Posted: Mon Jun 10, 2013 06:36 PM
I just get the notice from my client that the problem is not with ADO but with DBF also.


Maybe this is more evidence that it might be a memory leak in the app.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Problems with an application using ADO
Posted: Mon Jun 10, 2013 07:51 PM
James,

James Bott wrote:
I just get the notice from my client that the problem is not with ADO but with DBF also.


Maybe this is more evidence that it might be a memory leak in the app.

James


No, the problem is not in the applications. They worked fine before the last FWH update.

EMG
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Problems with an application using ADO
Posted: Mon Jun 10, 2013 08:16 PM
No, the problem is not in the applications. They worked fine before the last FWH update.


It still could be that either FWH or (x)Harbour introduced a memory leak with the last update.

james
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: Problems with an application using ADO
Posted: Mon Jun 10, 2013 08:38 PM

Hello,

I confirm you the problem with DBF and FW 13.05.

It was not in previous build, so it is related with MsgBar or changes in TControl/TWindow as a result of a post from Antonio´s at Harbour Developers list.

It is quite urgent.

It happens when you have the main window open with no activity in 15-20 minutes.

Best regards

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Problems with an application using ADO
Posted: Mon Jun 10, 2013 09:27 PM
James,

James Bott wrote:
No, the problem is not in the applications. They worked fine before the last FWH update.


It still could be that either FWH or (x)Harbour introduced a memory leak with the last update.

james


Yes, I agree.

EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Problems with an application using ADO
Posted: Mon Jun 10, 2013 09:29 PM
Lucas,

lucasdebeltran wrote:I confirm you the problem with DBF and FW 13.05.


Thank you.

EMG