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
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)
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 69 guests