FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour ads y archivo add.
Posts: 366
Joined: Wed Aug 30, 2006 05:25 PM
ads y archivo add.
Posted: Thu Feb 02, 2012 11:33 AM

Hola amigos:

Estoy comenzando con un proyecto nuevo y como es chico, voy a hacerlo con ADS Local.(Pero deseo usar .add por si las moscas)

Si alguien me puede dar una mano con los archivos .ADD Advantage Data Dictionary, se lo agradezco.
Como lo creo, como accedo a las bases de datos a traves del archivo. Como abro el mismo archivo 2 veces.

Muchas gracias.

(Despues vendran las de MySQL.)

Saludos
Ruben Fernmandez.

Gracias y Saludos

Ruben Fernandez - Uruguay

FWH 11.06, Harbour, Borland 5.82
Posts: 1074
Joined: Fri Oct 07, 2005 01:56 PM
Re: ads y archivo add.
Posted: Thu Feb 02, 2012 04:35 PM
Hola

Los diccionario se crean con el Data Arquitec,

te adjunto el codigo inicial para conectarte al diccionario

Code (fw): Select all Collapse
#include "ads.ch"
ANNOUNCE RDDSYS

procedure Main()

 // AQUI TU PROGRAMA PRINCIPAL

Return
//---------------------------------------------------------------------------------
Init Procedure Inicio()
    local hConnection := 0, lConecte := .f.

    SET MULTIPLE ON
    SET EPOCH TO 1950                            // Admite los años desde el 1990 en adelante
    SET CONFIRM ON
    SET CENTURY ON                               // 4 d¡gitos a¤o
    SET DATE FORMAT "DD/MM/YYYY"                 // formato dd-mm-yyyy
    SET DELETED ON                               // Impedir ver registros marcados borrar
    SetHandleCount( 150 )                        // M ximo n§ ficheros abiertos
    SET _3DLOOK ON
    SET CHARTYPE TO ANSI

    rddregister( "ADS", 1 )
    rddSetDefault( "ADS" )

    AdsSetCharType("OEM")
   AdsSetDateFormat( "DD/MM/YYYY" )
    AdsSetEpoch( 1950 )

    MsgRun( "Espere un momento, Conectando con el Servidor", "Sistema",;
             { || lConecte := AdsConnect60( "RUTA\ARCHIVO.ADD", ADS_LOCAL_SERVER, "adssys", "pass",, @hConnection ) } )

    if !lConecte
        MsgInfo( "Hay problemas en el servidor"+CRLF+"intente mas tarde", "usuario" )
        PostQuitMessage(0)
        QUIT
        return
    endif

    AdsSetServerType( ADS_LOCAL_SERVER )
    AdsSetFileType( ADS_CDX )
    AdsLocking( .T. )
    AdsRightsCheck( .T. )

return
//-----------------------------------------------------------------------------------------------------------------
procedure RddInit()
    REQUEST HB_LANG_ES
    REQUEST DBFCDX, DBFFPT
    REQUEST ADS
    REQUEST OrdKeyCount, OrdKeyNo, OrdKeyGoto, ADSKeyNo, AdsSetRelKeyPos, AdsGetRelKeyPos
return
//-----------------------------------------------------------------------------------------------------------------
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
Posts: 366
Joined: Wed Aug 30, 2006 05:25 PM
Re: ads y archivo add.
Posted: Thu Feb 02, 2012 05:29 PM

Muchas gracias Patricio.

Pruebo y mas tarde seguire molestando.

Muchas gracias de nuevo.

Saludos
Ruben Fernandez

Gracias y Saludos

Ruben Fernandez - Uruguay

FWH 11.06, Harbour, Borland 5.82
Posts: 128
Joined: Tue Jan 03, 2006 08:31 PM
Re: ads y archivo add.
Posted: Sun Feb 05, 2012 08:20 PM
Ruben. Para crear diccionarios de ADS desde codigo

Code (fw): Select all Collapse
 FUNCTION Main()
   LOCA lCreate
   LOCAL oIniFile, cLanIp, cLanPort, cInternetIp, cInternetPort, cServerType, cServerName, cDictionary
   LOCAL cIpFija, cPortFijo, cRootDrive, cUserServer, cServerPath, cPassServer, cErrorAds, cImageFondo

    REQUEST ADS ,  ADSKeyno, ADSKeycount, AdsGetRelKeyPos,  AdsSetRelKeyPos
    RddRegister( "ADS", 1 )      // ADS for Harbour
    RddSetDefault( "ADS" )       // ADS for Harbour
    AdsLocking( lLocking )
    AdsRightsCheck( lRightsCheck )
    AdsTestRecLocks( .T. )
    ADSCACHEOPENTABLES( nCacheOpenTables )
    AdsSetFileType( VAL( cServerType ) ) /// 1 NTX / 2 CDX / 3 ADT
    AdsSetDateFormat( cDateFormat )

    oIniFile     := TIniFile():New( cPathExe + "Ads.ini" )

    cLanIp       := oIniFile:ReadString( "SETTINGS", "LAN_IP", "" )
    cLanPort     := oIniFile:ReadString( "SETTINGS", "LAN_PORT", "" )
    cInternetIp  := oIniFile:ReadString( "SETTINGS", "INTERNET_IP", "" )
    cInternetPort:= oIniFile:ReadString( "SETTINGS", "INTERNET_PORT", "" )
    cServerType  := oIniFile:ReadString( "SETTINGS", "ADS_SERVER_TYPE", "" )
    cServerName  := oIniFile:ReadString( "SETTINGS", "ADS_SERVER_NAME", "" )
    cServerPath  := oIniFile:ReadString( "SETTINGS", "ADS_SERVER_PATH", "" )
    cImageFondo  := oIniFile:ReadString( "SETTINGS", "ADS_SERVER_JPEG", "" )

    lCreate := AdsDdCreate( cNameDictionary,, "Diccionario de datos ADS")   
 
   IF ! lCreate
       Alert( "DICCIONARIO DE DATOS NO CREADO")
      RETURN
   ENDIF
 IF cServerType == "1"
    cDictionary:= cServerPath + cServerName
    cIpFija    := ""
    cPortFijo  := ""
    cRootDrive := ""
 ELSEIF cServerType =="2" .OR. cServerType =="3"
    cDictionary:= cServerPath + cServerName
    cIpFija    := cLanIp
    cPortFijo  := ":" + cLanPort
    cRootDrive := "\\"
 ELSEIF cServerType == "4" .OR. cServerType =="7"
    cDictionary:= cServerPath + cServerName
    cIpFija    := cInternetIp
    cPortFijo  := ":" + cInternetPort
    cRootDrive := "\\"
 ENDIF
 AdsSetServerType( Val(cServerType) )

   oWait:= TMsgWait():New("CONECTANDOSE AL SERVIDOR REMOTO... UN MOMENTO POR FAVOR" )

  IF AdsConnect60( cRootDrive + cIpFija + cPortFijo + cDictionary, Val(cServerType), "AdsSys", "Edss18462",,@hCONN  )
      oWait:Close()
  ELSE
     oWait:Close()
     nError:= AdsGetLastError(@cErrorAds)
     Alert(  cErrorAds,;
             "ERROR DE ADS...")
    DBCloseAll()
    QUIT
 ENDIF
  
 // SI QUIERES USAR SQL CON LAS TABLAS QUE TENGAS EN EL DICCIONARIO.. TE RECOMIENDO QUE USES LAS TABLAS NATIVAS DE ADS. ADT EN VEZ DE DBF

 oWait:= TMsgWait():New("ABRIENDO ARCHIVOS DE DATOS, ESPERE UN MOMENTO POR FAVOR..." )

 lSqlQuery:= .F.
 cSqlQuery:= "SELECT * FROM CATGASTO ORDER BY ID_GASTO"
 IF Select( "CATGAS" ) > 0
    catgas->( DBCloseArea() )
 ENDIF
 DbSelectArea( 0 )
 IF ADSCreateSQLStatement( 'CATGAS', 3, hCONN )
    lSqlQuery:= ADSExecuteSQLDirect( cSqlQuery )
    IF !lSqlQuery
       oWait:Close()
       nError:= AdsGetLastError(@cErrorAds)
       ALERT( cErrorAds,'ERROR SCRIPT DE ADVANTAGE...'  )
       RETURN NIL
    ENDIF
 ELSE
    oWait:Close()
    nError:= AdsGetLastError(@cErrorAds)
    ALERT( cErrorAds,'ERROR SCRIPT DE ADVANTAGE...' )
    RETURN NIL
 ENDIF
 aGastos:= {}
 DBSelectArea( "CATGAS"); DBGoTop()
 DO WHILE !Eof()
    AAdd( aGastos, { catgas->ID_GASTO, Left(catgas->NOMBRE,25), catgas->TIPO, IF( catgas->TIPO="E", "EGRESO", "INGRESO") } )
    DBSkip()
 ENDDO


Saludos
GABO
Posts: 366
Joined: Wed Aug 30, 2006 05:25 PM
Re: ads y archivo add.
Posted: Mon Feb 06, 2012 10:26 AM

Gracias gabo: Estoy intentado por ahora en modo local con disccionario de datos.

Saluydos y gracias de nuevo.

Ruben Fernandez

Gracias y Saludos

Ruben Fernandez - Uruguay

FWH 11.06, Harbour, Borland 5.82

Continue the discussion