Hi,
Is it possible to use RecordSet along with DbCombo. ie just like using a DBF with ITEMFIELD and LISTFIELD. My intention is to avoid creating array and just assign a recordset to the DbCombo Control
Regards
Anser
Hi,
Is it possible to use RecordSet along with DbCombo. ie just like using a DBF with ITEMFIELD and LISTFIELD. My intention is to avoid creating array and just assign a recordset to the DbCombo Control
Regards
Anser
Hi Anser,
I thing is not possible, we need a new method "FillAdo", to do it. Internally dbCombo allways create array if is not recived via parameter.
Hi Mr.Biel,
Thankyou for the information. I think a METHOD like FillADO() is very much required so that ADO users can utilise this class.
So both DBF and ADO users can utilise DbCombo CLASS effectively. At present we have to read the recordset and create array and pass it to DbCombo
I hope Mr.Antonio will consider this requirement
Regards
Anser
METHOD AdoFill() CLASS TDBCombo
// Refill aItems and aList from oRecSet->cFldItem and oRecSet->cFldList
LOCAL nOldRecNo
LOCAL nItem, nList,uTest
IF ::oRecSet == NIL
// There's no RecordSet defined, so do nothing.
RETURN NIL
END IF
::aItems := {}
::aList := {}
TRY
uTest:=::oRecSet:Fields(::cFldItem):Value
CATCH
MsgAlert( "TDBCombo:AdoFill() - FieldName '" + ::cFldItem + "' not found." )
RETURN NIL
END
TRY
uTest:=::oRecSet:Fields(::cFldList):Value
CATCH
MsgAlert( "TDBCombo:AdoFill() - FieldName '" + ::cFldList + "' not found." )
RETURN NIL
END
nOldRecNo := (::oRecSet:Bookmark)
// Don't know why oRecSet:GetRows() not functioning, supposed to Return Array
* ::aItems := ::oRecSet:GetRows(,,::cFldItem)
* ::aList := ::oRecSet:GetRows(,,::cFldList)
::oRecSet:MoveFirst()
DO WHILE !(::oRecSet:Eof())
AADD( ::aItems, ::oRecSet:Fields(::cFldItem):Value)
AADD( ::aList, ::oRecSet:Fields(::cFldList):Value)
::oRecSet:MoveNext()
EndDo
::oRecSet:Bookmark:=nOldRecNo
RETURN NIL// Sql used to create the recordset
cSql:="Select UserName,User_Id from users where Branch_ID= 1"
// oRecSet is the RecordSet Object
@2.3,1 DBCOMBO oDbCmb VAR nUserId ;
size 120,200 ; // Size Control width, Ht of the list when activated
of oDlg;
ITEMFIELD "User_ID" ;
LISTFIELD "UserName" ;
RECORDSET oRecSet ;
ON CHANGE MsgInfo(nUserId)What I think would be a better long-term solution is to create array and recordset classes.
Rather than adding code for DBFs, arrays, and recordsets to all kinds of controls, it makes more sense to me to create array and recordset classes that work just like the TDatabase class. This way the same code in the controls works for all data sources.
The current method of adding code to many controls for each datasource type makes each control more complex and more difficult to modify--each modification needs to account for all datasources.
Another added benefit of datasource classes would be that any code you have written to use a database object could be very simply converted to using an array or recordset object by just changing the datasource object. Simple.
Regards,
James