by Rick Lipkin » Thu May 03, 2007 9:31 pm
Rene
I am using the 'standard' code .. I presume the recordset is being cached to the local workstation ?
Here is the code:
// access.prg
#include "Fivewin.ch"
Static lOK,oWND1,oBRW,oBROW,oBROW2
Static oSAY, cSAY, oSAY1, cSAY1
//-------------------------------------------
Func Access()
LOCAL oErr, SAYING, cFILENUM, oCN, cNAME, nLEN, nPOS, oRs, oDLG
LOCAL lOK
SET CENTURY on
SET EPOCH to 1990
SET DELETED on
oRs := CREATEOBJECT( "ADODB.Recordset" )
TRY
oRS:Open( "SELECT * FROM CERT_DATA order by Name", "Provider=SQLOLEDB;Data Source=WEBDB02;Initial Catalog=DRUG_CONTROL;User Id=drugcontroluser;Password=r2x6j3q4", 1,3 )
CATCH oErr
MsgInfo( "Error in Opening CERT_DATA table" )
RETURN NIL
END TRY
* oRs:MoveFirst()
_CertBrow(oRs )
Return(nil)
//--------------------------------------------------------
STATIC FUNCTION _CertBrow( oRs )
LOCAL nRec, oDLG
lOK := .F.
DEFINE WINDOW oWnd1 ;
FROM 3,1 to 30,100 ;
Menu Buildmenu(oRS);
TITLE "REGISTRATION Registration Information Browse"
@ 0,0 LISTBOX oBrw FIELDS ;
oRs:Fields( "name" ):Value,;
oRs:Fields( "addr1" ):Value,;
oRs:Fields( "addr2" ):Value,;
oRs:Fields( "addr3" ):Value,;
oRs:Fields( "city" ):Value,;
oRs:Fields( "state" ):Value,;
oRs:Fields( "zip" ):Value,;
oRs:Fields( "zip4" ):Value,;
oRs:Fields( "schd" ):Value,;
dtoc( oRs:Fields( "expir_date" ):Value),;
dtoc( oRs:Fields( "init_date" ):Value );
SIZES 300,100,100,100,80,80,80,80,80;
HEADERS "Name",;
"Address1 ",;
"Address2 ",;
"Address3 ",;
"City ",;
"State",;
"Zip ",;
"Zip4 ",;
"Schd ",;
"Expire Date",;
"Init_date ";
ON DBLCLICK( MsgInfo( "Mark Record to Keep" ) );
UPDATE
oBrw:bLogicLen := { || oRs:RecordCount }
oBrw:bGoTop := { || oRs:MoveFirst() }
oBrw:bGoBottom := { || oRs:MoveLast() }
oBrw:bSkip := { | nSkip | Skipper( oRs, nSkip ) }
oBrw:cAlias := "ARRAY"
oWND1:oClient := oBRW
ACTIVATE WINDOW oWND1 ;
VALID ( IIF( !lOK, _LwmfsClose(.T., oRs), .F. ))
RETURN NIL
//------------------------
Static FUNCTION _LwmfsClose( lCLEAN, oRS )
IF lCLEAN = .T.
lOK := .T.
oBRW:cALIAS := nil
oRs:Close()
ENDIF
RETURN(.T.)
//--------------------------------------
Static FUNCTION BuildMenu( oRS )
LOCAL oMenu1
MENU oMenu1
MENUITEM "&Find ..." // ;
* ACTION ( _DocFind( oRS ), ;
* oBRW:Refresh() ) ;
* MESSAGE "Find a Site"
MENUITEM "&Quit" ;
ACTION oWnd1:END()
ENDMENU
RETURN( oMenu1 )
//-------------------------------
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 )
//----------------------
Static Func _Docfind(oRS)
LOCAL cITEM, oDLG,olbx
cITEM := "File Number"
DEFINE DIALOG oDlg ;
FROM 1, 3 to 18, 35 ;
TITLE "Site Locate Routine"
@ 0,0 LISTBOX oLBX var cITEM ;
ITEMS { "File Number" } ;
on LEFT DBLCLICK _FINDENTR(cITEM,oDLG,oRS) ;
of oDlg SIZE 120,100 ;
MESSAGE "Please select an Item"
@ 6,4 BUTTON "&Ok" ;
SIZE 25,10 of oDLG ;
ACTION( _FINDENTR(cITEM, oDLG, oRS), ;
oDLG:END(), cITEM := NIL ) ;
DEFAULT
@ 6,11 BUTTON "&Quit" ;
SIZE 25,10 of oDLG ;
ACTION oDlg:END()
ACTIVATE DIALOG oDlg
oDLG:END()
RETURN( NIL )
//-----------------------
Static FUNC _FINDENTR( cITEM,oDLG,oRS )
LOCAL cFIND, cTITLE, oDLG2
cFIND := "BOGUS"
DO CASE
CASE cITEM = "File Number"
cFIND := SPACE(10)
cTITLE := "Enter a File Number"
ENDCASE
DEFINE DIALOG oDlg1 ;
FROM 14,10 to 21,44 ;
TITLE cTITLE
@ 1,1 GET cFIND of oDLG1 PICTURE "@!"
@ 2,6 BUTTON "&Ok" ;
SIZE 25,10 of oDLG1 ;
ACTION ( GoGetum( cFIND, oRS, cITEM),;
oDlg1:END(), oDLG:END() ) ;
DEFAULT
@ 2,13 BUTTON "&Quit" ;
SIZE 25,10 of oDLG1 ;
ACTION ( oDlg1:END(), oDLG:END() )
ACTIVATE DIALOG oDlg1
oDLG1:END()
RETURN( NIL )
//---------------------------
Static FUNC GoGetum( cFIND,oRS, cITEM )
LOCAL SAYING, nRECNO, oBTN1,oBTN2
LOCAL lOK
cFIND := ALLTRIM( cFIND )
DO CASE
CASE cITEM = "File Number"
oRs:Find("file_num = '"+cFIND+"'" )
IF oRs:eof
oRs:MoveFirst()
oRs:Find("file_num = '"+cFIND+"'" )
IF oRs:eof()
Msginfo( "File Number "+cFind+" can not bre found" )
oRs:MoveFirst()
ENDIF
ENDIF
RETURN(.T.)
ENDCASE
RETURN(NIL)
// -- END