Hi,
Is it possible to work with the Sqlite database via FWH ?
oConG := OpenSQLite( oConG )
cCad := "SELECT * FROM DOCUMENTO"
oObj := SSQLQry( oConG, oObj, cCad )
IF oObj:RecordCount() =0
cCad := "INSERT INTO DOCUMENTO (NUM_RUC, TIP_DOCU, NUM_DOCU) VALUES ('00000000000','','')"
lOK := oConG:Execute( cCad )
EndIf
cCad := "UPDATE PARAMETRO SET val_para = '1' WHERE cod_para = 'TIMEENVIA'"
lOK := oConG:Execute( cCad )
//---------------------------------------------------------------------------------------------------------------
Function OpenSQLite( oConL )
oConL := TOleAuto():new( "adodb.connection" )
oConL:ConnectionString := "Data Source=archivosfs;Version=3;New=True;Compress=True;"
TRY
oConL:Open()
CATCH
MsgStop( "No Hay Conexion ODBC - SQLIte", "Error", 2 )
oConL := Nil
QUIT
QUIT
END
SysRefresh()
Return( oConL )
//-----------------------------------------------------------------------------------------------------------------------------
Function SSQLQry( oConT, oRs1, cCon )
oRs1 := FW_OpenRecordSet( oConT, cCon )
Return( oRs1 )
//----------abrir una SQLITE.DB
//---------------------------------------------------------------------------------------------------------------
Function OpenSQLite( oConL )
oConL := TOleAuto():new( "adodb.connection" )
oConL:ConnectionString := "Data Source=sqlitedat;Version=3;New=True;Compress=True;" // sqitedat es el nombre indicado en el ODBC
TRY
oConL:Open()
CATCH
MsgStop( "No Hay Conexion ODBC - SQLIte", "Error", 2 )
oConL := Nil
QUIT
QUIT
END
SysRefresh()
Return( oConL )
//-------hacer una consulta
...
cCad := "SELECT cod_para, val_para FROM TXXXX_PARAM"
oObj := SSQLQry( oConL, oObj, cCad )
WHILE !oObj:EOF()
IF SQLvar( oObj, 0 ) = "FUNCIO"
cMen := "SFS : " + IF(SQLVar( oObj, 1 ) = "01", "AUTOMÁTICO","MANUAL")
EndIf
oObj:Move(1)
ENDDO
//---------------------------------------------------------------------------------------------------------
Function SSQLQry( oConT, oRs1, cCon )
oRs1 := FW_OpenRecordSet( oConT, cCon )
Return( oRs1 )
//------------update datos
...
cCad := "UPDATE TXXXX_PARAM SET val_para = '0.2' WHERE cod_para = 'TIEMPO'"
lOK := oConL:Execute( cCad )
//-----------------------------------------------------------------------------------------------------------------------------
Function SQLVar( oObj, nCampo )
local cVar
TRY
cVar := oObj:Fields( nCampo ):Value
CATCH
cVar := ""
END
Return( cVar )
//-------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------
Function SetBrow(oDataS, oBrw)
local lRet := .t.
local bGoTop, bGoBottom, bSkipper, bSkip
local cClsName
bGoTop := { || If( oDataS:RecordCount() > 0, oDataS:MoveFirst(), nil ) }
bGoBottom := { || If( oDataS:RecordCount() > 0, oDataS:MoveLast(), nil ) }
bSkip := { | n | AdoSkip( oDataS, IfNil( n, 1 ) ) }
bSkipper := { | n | AdoSkip( oDataS, IfNil( n, 1 ) ) }
oBrw:cAlias := ""
oBrw:bGoTop := bGoTop
oBrw:bGoBottom := bGoBottom
oBrw:bSkip := bSkipper
oBrw:bLogicLen := { || oDataS:RecordCount() }
if oBrw:oVScroll() != nil
oBrw:oVscroll():SetRange( 1, oDataS:RecordCount() )
endif
oBrw:Refresh()
Return(NIl)
static function AdoSkip( oRs, n )
LOCAL nRec
if oRs:RecordCount() == 0
return 0
endif
nRec := oRs:AbsolutePosition
If( oRs:Eof, oRs:MoveLast(), If( oRs:Bof, oRs:MoveFirst(),) )
oRs:Move( n )
If( oRs:Eof, oRs:MoveLast(), If( oRs:Bof, oRs:MoveFirst(),) )
return oRs:AbsolutePosition - nRec
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 24 guests