FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TDataRow and ADO questions
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM
Re: TDataRow and ADO questions
Posted: Wed Jun 12, 2013 10:28 AM

Thank you very much.

And what is the equivalent please for:

SUM FIELD->TOTAL TO nt

Thanks.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: TDataRow and ADO questions
Posted: Wed Jun 12, 2013 10:40 AM
Elvira,

elvira wrote:Thank you very much.

And what is the equivalent please for:

SUM FIELD->TOTAL TO nt

Thanks.


You can just iterate through the records adding the field values. Or, better, you can use a query like this:

Code (fw): Select all Collapse
SELECT SUM( Total ) AS nt FROM MyTable WHERE MyCondition


and later:

Code (fw): Select all Collapse
? oRs:Fields( "nt" ):Value


EMG
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM
Re: TDataRow and ADO questions
Posted: Wed Jun 12, 2013 01:56 PM

Thank you Enrico.

One little question more, as now we don´t have to do PACK o Reindex, is there any command via SQL sentence to issue from time to time to optimize the database?:

Kind regards ;)

Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: TDataRow and ADO questions
Posted: Wed Jun 12, 2013 02:29 PM

Elvira:

If you speak Spanish let me know your email address.

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: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: TDataRow and ADO questions
Posted: Wed Jun 12, 2013 02:49 PM
Elvira,

elvira wrote:Thank you Enrico.

One little question more, as now we don´t have to do PACK o Reindex, is there any command via SQL sentence to issue from time to time to optimize the database?:

Kind regards :-)


Yes, but only for MDB database:

Code (fw): Select all Collapse
LOCAL cCn1 := "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MyDatabase.mdb"
LOCAL cCn2 := "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MyCompactedDatabase.mdb"

LOCAL oJro

oJro = CREATEOBJECT( "JRO.JetEngine" )

oJro:CompactDatabase( cCn1, cCn2 )


EMG
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: TDataRow and ADO questions
Posted: Wed Jun 12, 2013 07:35 PM

Hi Mr. Rao,

Is xBrowse works with array of TDataRow?

Thanks

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM
Re: TDataRow and ADO questions
Posted: Thu Jun 13, 2013 06:44 AM

Mr. Enrico,

Thank you a lot.

Appart from w3schools, is there a book preferent to learn ADO?. For example, the compact of database is not explanied at that site.

Also, Microsoft.Jet.OLEDB.4 works in Windows 8?.

Thanks. Kind regards

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: TDataRow and ADO questions
Posted: Thu Jun 13, 2013 08:14 AM
Elvira,

elvira wrote:Mr. Enrico,

Thank you a lot.


We are here to help and serve. :-)

elvira wrote:Appart from w3schools, is there a book preferent to learn ADO?. For example, the compact of database is not explanied at that site.


Because it's not related with ADO. It's another class hierarchy (JRO).

elvira wrote:Also, Microsoft.Jet.OLEDB.4 works in Windows 8?.


I don't know for sure but it should work.

EMG
Posts: 109
Joined: Mon Apr 30, 2012 09:10 AM
Re: TDataRow and ADO questions
Posted: Thu Jun 13, 2013 09:01 AM

Hello,

very very interesting and useful topic ;), as we are wainting TDatarow to be fixed and start using ADO too.

I was wondering if ADO works with FWH64 bits, for SQL, MySQL and Access.

Best regards,

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: TDataRow and ADO questions
Posted: Thu Jun 13, 2013 10:20 AM
Also, Microsoft.Jet.OLEDB.4 works in Windows 8?.

Yes it works.

And it is also time to start using latest ACE.OLEDB drirvers instead of Jet.

Is xBrowse works with array of TDataRow?


It is just the opposite of the intention with which TDataRow class is created.

The intention is to collect the field (column) information of a single row of a table ( of any datasource ) for modification/adding and then saving the information. The process of reading and saving is transparent the application program, so that the same code can be used for all kinds of datasources.

Still to answer your question, Yes we can create an xbrowse with an array of TDataRow objects, but that is of no special advantage.
Regards



G. N. Rao.

Hyderabad, India
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM
Re: TDataRow and ADO questions
Posted: Fri Jun 14, 2013 02:22 PM

Hello,

When the table is empty in ADO, operations such as oRs:AbsolutePosition block the program instead of giving an error.

Other commands, such as oRs:Movefirst() do produce an error.log.

In DBF for example in a database with no records, you could issue dbgotop() or dbgobottom() with no problems, but oRs:Movefirst() fails.

Is there a way in ADO that they don´t produce such behaviour and work as DBF in an empty table?.

Thanks!

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: TDataRow and ADO questions
Posted: Fri Jun 14, 2013 02:39 PM
Elvira,

elvira wrote:Hello,

When the table is empty in ADO, operations such as oRs:AbsolutePosition block the program instead of giving an error.

Other commands, such as oRs:Movefirst() do produce an error.log.

In DBF for example in a database with no records, you could issue dbgotop() or dbgobottom() with no problems, but oRs:Movefirst() fails.

Is there a way in ADO that they don´t produce such behaviour and work as DBF in an empty table?.

Thanks!


No, you have to check for the !empty table first or trap the error.

EMG
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM
Re: TDataRow and ADO questions
Posted: Fri Jun 14, 2013 02:46 PM

Enrico, thank you.

So I have to use many try/catch, but won´t be too slow for the application performance?.

Thankls

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: TDataRow and ADO questions
Posted: Fri Jun 14, 2013 02:59 PM
Elvira,

elvira wrote:Enrico, thank you.

So I have to use many try/catch, but won´t be too slow for the application performance?.

Thankls


No, you don't have to. You can just open the table and test for !oRs:EOF. Then go on with the rest of the code if the table is not empty.

EMG
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: TDataRow and ADO questions
Posted: Fri Jun 14, 2013 04:24 PM
Elvira

Enrico has given you some GREAT advice!! .. I started with ADO many years ago with his help.

A couple of ADO 'gotchas' you need to know ..

1) When working with SQL databases, you have to be aware of NULL fields. When you Add or Edit a Sql row, it is best to apply a VALUE to each field even if it is " " or ctod(""). Unlike .Dbf .. if you do not apply a value to a field, SQL assigns it 'NULL' and if you try to manipulate that field without realizing it was NULL, your program will fail at run-time.

2) Also .. if you are using xHarbour .. there is a new dataType "T" for Date\Time and if you assign a DateTime value to a variable or try to manipulate that value like valtype "D" you will run into all kinds of problems.

Many of our ADO friends use a function like this to convert Valtype "T" back to Valtype "D"

Code (fw): Select all Collapse
//--------------------------
Function TtoDate( tDate )

If empty( tDate)
   Return( ctod("00/00/00"))
Endif

If ValType( tDate ) = "D"
   Return(tDate )
Endif

Return( stod( substr( ttos( tDate ), 1, 8 ) ))


and when you assign a DateTime value to a variable I would suggest this
Code (fw): Select all Collapse
dDob          := If( empty(oRsPet:Fields("Dob"):Value), ctod("00/00/00"),;
                        TtoDate(oRsPet:Fields("Dob"):Value))

Rick Lipkin