"...the fact that xbrowse is terrible with ADS RDDs, even with the Local and/or Remote servers and not just AIS."
function Test_SQL()
LOCAL cSql := ""
LOCAL aArray := {}
LOCAL cAlias := Alias()
/*al inicio de la instruccion sql se define un area vacia*/
DBSelectArea(0)
/*se define instruccion sql en una cadena de texto*/
cSql := "SELECT * FROM CUSTOMER"
msgINFO(csql, "cSql")
/*crea instruccion sql y pasa los datos a tabla temporal*/
ADSCreateSQLStatement( "REPTMP", 2 )
IF ADSExecuteSQLDirect( cSql )
DBSelectArea("REPTMP")
REPTMP->( DBGoTop() )
IF LastRec() > 0 // !REPTMP->( Eof() )
/*lista resultado en tabla*/
xbrowse()
//aArray := FW_DbfToArray()
//XBROWSER aArray
ELSE
/*no se encontro datos que cumpla condicion sql*/
MsgInfo( "No se ha encontrado REGISTROS" )
ENDIF
/*cierra tabla de datos temporal*/
REPTMP->( DBCloseArea() )
ELSE
Alert( "AdsExecuteSQLDirect() failed with error "+ Str( ADSGetLastError() ) )
ENDIF
/*se selecciona area de datos anterior*/
IF !Empty(cAlias)
DBSelectArea(cAlias)
ENDIF
/*da foco al browse*/
RETURN NIL
oRsDEP:= TOleAuto():New( "ADODB.Recordset" )
oRsDEP:CursorType := 1 // opendkeyset
oRsDEP:CursorLocation := 3 // local cache
oRsDEP:LockType := 3 // lockoportunistic
cSQL := "SELECT * FROM FREQUENCY order by FREQUENCY"
TRY
oRsDEP:Open( cSQL,xCONNECT )
CATCH oErr
MsgInfo( "Error in Opening FREQUENCY table" )
RETURN(.F.)
END TRY
Do Case
Case nType = 1
IF EMPTY( zFrequency )
zFrequency := "BOGUS"
ENDIF
Case nType = 2
IF EMPTY( zT_Freq )
zT_Freq := "BOGUS"
ENDIF
End Case
*cNAME := UPPER(ALLTRIM(cNAME))
IF oRsDep:eof
ELSE
IF .not. oRsDEP:eof
oRsDEP:MoveFirst()
ENDIF
Do Case
Case nType = 1
oRsDEP:Find( "FREQUENCY LIKE '"+upper(alltrim(zFrequency))+"%'" )
Case nType = 2
oRsDEP:Find( "FREQUENCY LIKE '"+upper(alltrim(zT_Freq))+"%'" )
End Case
IF oRsDEP:eof
oRsDEP:MoveFirst()
ENDIF
ENDIF
lOK2 := .F.
DEFINE DIALOG oDlg RESOURCE "FREQSLCT" ;
COLOR "W+/W" ;
TITLE "Frequency Select" ;
REDEFINE LISTBOX oLBX FIELDS ;
IF(oRsDep:eof," ",oRsDep:Fields("FREQUENCY"):Value);
HEADERS "Frequency" ;
SIZES 90 ;
ID 111 of oDlg ;
UPDATE
REDEFINE BUTTON oBTN1 ID 113 ;
ACTION ( if(nTYPE = 1, zFREQUENCY := oRsDep:Fields("FREQUENCY"):Value, ), ;
if(nTYPE = 1, zFREQUENCYEID := oRsDep:Fields("FREQUENCYEID"):Value, ),;
if(nTYPE = 2, zT_FREQ := oRsDep:Fields("FREQUENCY"):Value, ), ;
if(nTYPE = 2, zT_FREQEID := oRsDep:Fields("FREQUENCYEID"):Value, ),;
lOK2 := .T.,;
oOBJ:Refresh(), ;
oLbx:ReFresh(), ;
oDlg:END() )
REDEFINE BUTTON oBTN2 ID 112 ;
ACTION ( lOK2 := .F., oDlg:END() )
REDEFINE BUTTON oBTN3 ID 114 ;
ACTION ( _FreqView("A", oRsDep ), ; // depview.prg
if(oRsDep:eof, ,oLBX:bLogicLen := { || oRsDep:RecordCount }),;
if(oRsDep:eof, ,oLBX:bGoTop := { || oRsDep:MoveFirst() }),;
if(oRsDep:eof, ,oLBX:bGoBottom := { || oRsDep:MoveLast() }),;
if(oRsDep:eof, ,oLBX:bSkip := { | nSkip | Skipper( oRsDep, nSkip )}),;
if(oRsDep:eof, ,oLBX:cAlias := "ARRAY"),;
oLBX:ReFresh(),;
oLBX:SetFocus(),;
SysReFresh() )
IF .not. oRsDep:eof
oLbx:bLogicLen := { || oRsDEP:RecordCount }
oLbx:bGoTop := { || oRsDEP:MoveFirst() }
oLbx:bGoBottom := { || oRsDEP:MoveLast() }
oLbx:bSkip := { | nSkip | Skipper( oRsDEP, nSkip ) }
oLbx:cAlias := "ARRAY"
ENDIF
ACTIVATE DIALOG oDlg ;
ON INIT ( if( xSUPER = 'Y', ,oBtn3:Hide() ) )
oRsDEP:CLose()
IF lOK2 = .F.
DO CASE
CASE nTYPE = 1
zFREQUENCY := SPACE(10)
zFREQUENCYEID := "BOGUS"
CASE nTYPE = 2
zT_FREQ := SPACE(10)
zT_FREQEID := "BOGUS"
ENDCASE
oOBJ:ReFresh()
ENDIF
SysReFresh()
RETURN( .T. )
//-------------------------------
STATIC FUNCTION SKIPPER( oRsx, nSkip )
LOCAL nRec := oRsx:AbsolutePosition
oRsx:Move( nSkip )
IF oRsx:EOF; oRsx:MoveLast(); ENDIF
IF oRsx:BOF; oRsx:MoveFirst(); ENDIF
RETURN( oRsx:AbsolutePosition - nRec )
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 27 guests