TDataRow and ADO questions

Re: TDataRow and ADO questions

Postby elvira » Wed Jun 12, 2013 10:28 am

Thank you very much.

And what is the equivalent please for:

SUM FIELD->TOTAL TO nt

Thanks.
elvira
 
Posts: 516
Joined: Fri Jun 29, 2012 12:49 pm

Re: TDataRow and ADO questions

Postby Enrico Maria Giordano » 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: Select all  Expand view
SELECT SUM( Total ) AS nt FROM MyTable WHERE MyCondition


and later:

Code: Select all  Expand view
? oRs:Fields( "nt" ):Value


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: TDataRow and ADO questions

Postby elvira » Wed Jun 12, 2013 1: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 ;)
elvira
 
Posts: 516
Joined: Fri Jun 29, 2012 12:49 pm

Re: TDataRow and ADO questions

Postby Armando » Wed Jun 12, 2013 2: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
User avatar
Armando
 
Posts: 3223
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: TDataRow and ADO questions

Postby Enrico Maria Giordano » Wed Jun 12, 2013 2: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: Select all  Expand view
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
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: TDataRow and ADO questions

Postby Horizon » Wed Jun 12, 2013 7:35 pm

Hi Mr. Rao,

Is xBrowse works with array of TDataRow?

Thanks
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: TDataRow and ADO questions

Postby elvira » Thu Jun 13, 2013 6: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
elvira
 
Posts: 516
Joined: Fri Jun 29, 2012 12:49 pm

Re: TDataRow and ADO questions

Postby Enrico Maria Giordano » Thu Jun 13, 2013 8: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
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: TDataRow and ADO questions

Postby joseluispalma » Thu Jun 13, 2013 9: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,
joseluispalma
 
Posts: 109
Joined: Mon Apr 30, 2012 9:10 am

Re: TDataRow and ADO questions

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: TDataRow and ADO questions

Postby elvira » Fri Jun 14, 2013 2: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!
elvira
 
Posts: 516
Joined: Fri Jun 29, 2012 12:49 pm

Re: TDataRow and ADO questions

Postby Enrico Maria Giordano » Fri Jun 14, 2013 2: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
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: TDataRow and ADO questions

Postby elvira » Fri Jun 14, 2013 2:46 pm

Enrico, thank you.

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

Thankls
elvira
 
Posts: 516
Joined: Fri Jun 29, 2012 12:49 pm

Re: TDataRow and ADO questions

Postby Enrico Maria Giordano » Fri Jun 14, 2013 2: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
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: TDataRow and ADO questions

Postby Rick Lipkin » Fri Jun 14, 2013 4: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: Select all  Expand view

//--------------------------
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: Select all  Expand view

dDob          := If( empty(oRsPet:Fields("Dob"):Value), ctod("00/00/00"),;
                        TtoDate(oRsPet:Fields("Dob"):Value))
 

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: karinha, nageswaragunupudi and 106 guests