The new class TDataRow is very exciting
We expect that this class will be very useful. Now it is useful for RDD, ADO, TDataBase, XBrowse with facility to build custom data. This class can be used to edit and appends.
We shall give enough examples and explanations soon about this class.
how do I load an array with a field from the Recordset so as to have, i.e., a combobox?. Here is how I do now
You have given a sample code of how you are now doing it with DBF.
Before we discuss ADO, let us see another simpler way to do it with DBF.
- Code: Select all Expand view
TIPO->( DbGoTop() )
aTipos := ArrTranspose( TIPO->( FW_DbfToArray( "TIPO" ) ) )[ 1 ]
TIPO->( DbGoTop() )
Now, let us come to ADO.
You open the record set as you normally do. Using FW built-in functions simplify your work.
Method-1: Same way very similar to how you are extracting the array from DBF
- Code: Select all Expand view
aTipos := {}
oRs:MoveFirst()
do while ! oRs:Eof()
AAdd( aTipos, oRs:Fields( "TIPO" ):Value )
oRs:MoveNext()
enddo
oRs:MoveFirst()
Now let us see if we have better alternatives.
Recordset has a method GetRows() which reads entire record set into a multi-dimentional array.
aData := oRs:GetRows()
Now let us use this method to get our work done.
I shall give here a sample using STATES.DBF in c:\fwh\samples folder. I shall open this table through ADO, using FW functions.
- Code: Select all Expand view
function ReadStatesArray()
local oCn, oRs, aStates
if ( oCn := FW_OpenAdoConnection( "c:\fwh\samples" ) ) != nil
if ( oRs := FW_OpenRecordSet( oCn, "SELECT CODE FROM STATES" ) ) != nil
oRs:MoveFirst()
aStates := ArrTranspose( oRs:GetRows() )[ 1 ]
oRs:MoveFirst()
oRs:Close()
else
? "Open Table Fail"
endif
oCn:Close()
else
? "Connect Fail"
endif
return aStates
what is the equivalent for recordset DO WHILE !EOF() and, also, Dbskip()?.
oRs:MoveFirst() // GoTop
oRs:MoveLast() // gobottom
oRs:MoveNext() // skip( +1 )
oRs:MovePrevious() // skip( -1 )
oRs:Move( n ) // Skip( n )
oRs:Bof() and oRs:Eof() // same as dbf
Advise you to learn all about ADO from w3schools website.
http://www.w3schools.com/ado/default.aspYou will learn almost all about ADO.