FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour expert of ADS and Harbour
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
expert of ADS and Harbour
Posted: Fri Mar 23, 2012 10:01 AM

Hello,

Please, who are the exports of ADS and Harbour?.

Thank you.

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: expert of ADS and Harbour
Posted: Sun Mar 25, 2012 07:55 PM
Hello,

I have a problem with AIS and free tables.


I am able to use and work with DBFS and AIS when tables are
incorporated into a Data Dictorionary. There is no problem about that.


But in our software we have so many companies and each one has a
specific folder with all the dbfs and indexes (CUSTOMERS, INVOICES,
ITEMS, ...).


So that麓s why I am looking to use free tables.


I am able to create a free table with dbcreate():


i := dbCreate( ("\\my ip:2400\lucas\newtable"),{ { "FNUMERO" ,
"N", 20, 0 }, ;
{ "FCODIGO" , "C", 20, 0 }, ;
{ "FPARCIAL2" , "N", 24, 10 } } )



Also, I am able to delete a file:


AdsDeleteFile("C:\LUCAS\ALBARAN1.DBF")



But I can麓t open the table in AIS as:


USE "C:\LUCAS\ALBARAN1" or USE "\\my ip:2400\LUCAS\ALBARAN1"


In both cases, I get:


Error ADSCDX/5132 The specified database object name is not valid.: C:
\LUCAS\ALBARAN1.DBF


At sybase forums, they said it is possible to use free tables via AIS.


In this post, Rene Flores says it is a bug and it worked as I pretend
in previous xHarbour builds (with xharbour 0.99.3 and previous):
viewtopic.php?f=6&t=6819


So, I am able to deal with free tables under AIS just with dbCreate
and AdsDeleteFile.


But USE or AdsCheckExistence fail.


Is there any solution to solve the bug?.


Thank you very much for your help.

Best regards,


Lucas
Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: expert of ADS and Harbour
Posted: Mon Mar 26, 2012 11:37 AM
Lucas,

no problem to open free tables.

If you are using xHarbour, you can even establish connections to different servers and open tables on these servers, see sample:
Code (fw): Select all Collapse
聽 聽// ALS connection
聽 聽IF AdsConnect60( cPathLoc, ADS_LOCAL_SERVER, "ADSSYS",, 0, @nHandLoc) == .F.
聽 聽 聽 nError:=AdsGetLastError(@cError)
聽 聽 聽 ? cError
聽 聽 聽 return NIL
聽 聽ENDIF
聽 聽
聽 聽// Open a dbf
聽 聽// DbUseArea( [<lNewArea>], [<cRddName>], <cDatabase>, [<cAlias>], [<lShared>], [<lReadonly>], [<cCodePage>], [<nConnection>] )
聽 聽 DbUseArea( .T., "ADSCDX", cPathLoc + "PRMTR.DBF", "prm_loc", .T.,,, nHandLoc )
聽 聽 
聽 聽// ADS connection
聽 聽IF AdsConnect60( cPathRem, ADS_REMOTE_SERVER, "ADSSYS",, 0, @nHandRem) == .F.
聽 聽 聽 nError:=AdsGetLastError(@cError)
聽 聽 聽 ? cError
聽 聽 聽 return NIL
聽 聽ENDIF
聽 聽
聽 聽// Open a dbf
聽 聽 DbUseArea( 聽 聽 聽 聽 聽 聽.T., 聽 聽 "ADSCDX", cPathRem + "PRMTR.DBF", "prm_rem", 聽 聽 聽 聽 .T., 聽 聽 聽 聽 聽 聽 聽, 聽 聽 聽 聽 聽 聽 聽, nHandRem )

聽 聽// Check if ADS or ALS is running
聽 聽lADS := AdsConnect( cPathRem ) // -> .T.
聽 聽lADS := AdsConnect( cPathLoc ) // -> .F.
Windows 11 Pro 22H2 22621.1848

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

Harbour 3.2.0dev (r2008190002)

FWH 23.10 x86
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: expert of ADS and Harbour
Posted: Mon Mar 26, 2012 04:22 PM

Frank,

Thank you.

But using AIS via Internet it gives:

DbUseArea( .T., "ADSCDX", "C:\LUCAS\CONTA.DBF", "LUCAS" )

Error ADSCDX/5132 The specified database object name is not valid.: C:\LUCAS\CONTA.DBF

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: expert of ADS and Harbour
Posted: Mon Mar 26, 2012 05:44 PM
hay que entender que la conexion en AIS se hace a traves de socket, por ello no funcionan algunas intrucciones que hacen referencia al disco duro
funciones como dbcreate, file no funcionaran, por que no tienes acceso directo al disco del server.
DbUseArea( .T., "ADSCDX", "C:\LUCAS\CONTA.DBF", "LUCAS" )

aca tu estas intentando usar una tabla alojada en c:\lucas lo cual no es posible.

es posible crear tablas en el servidor con la intruccion create table, o modificar tablas con alter tables, y en casos puntuales, crear tablas usando los drivers
dbfcdx o dbfntx para se usados de forma local en la pc cliente.

incluso tanto harbour como xharbour permiten usar tablas en memoria o tablas temporales,
Code (fw): Select all Collapse
dbcreate( "mem:FICHA1", aEstructura , "DBFCDX" )
...
HB_DBCreateTemp( "FICHA1", aEstructura , "DBFCDX" )



salu2
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 7
Joined: Wed Sep 01, 2010 05:29 AM
Re: expert of ADS and Harbour
Posted: Mon Mar 26, 2012 06:02 PM

The location of the Internet-enabled Advantage Database Server must be specified. In addition, you must also configure your application to use the Advantage Internet Server server type. See Connecting Clients through the Internet to Advantage for details. Below are the three ways to specify the location of the Internet-enabled Advantage Database Server:

1. Use the server's IP address and Internet port number in the connection path string. The path can be specified as \\<ip address>:<ip port>\share\Dir\DataDictionary.add, where the <ip address> is the IP address where the Advantage Database Server is located, and the <ip port> is the Internet Port that the Advantage Database Server is listening.

Example of using the server鈥檚 IP address and Internet port number with the Advantage Client Engine API:

ulRetVal = AdsConnect60("\\\\193.69.232.1:6262\\share1\\test.add",
ADS_AIS_SERVER,
"User1",
"foobar",
ADS_DEFAULT,
&hConnect );

Similar functionality for specifying the IP address and port in the connection string/path is available in other Advantage clients. The details related to making a connection through the Internet to the Advantage Database Server from other clients can be found in the respective Advantage client Help documentation.

2. Specify the server name in the connection string. The path can be specified as \\<server name>\share\Dir\DataDictionary.add, where the <server name> is the name of a server specified in the ADS.INI file. The ADS.INI file specifies the actual IP address where the Advantage Database Server is located, and IP port that the Advantage Database Server is listening, that correspond to the specified server name. See Setting Up Your Clients Using ADS.INI for more specifics on information in the ADS.INI file.

Example of using a server name with the Advantage Client Engine API:

ulRetVal = AdsConnect60( "\\\\server1\\share1\\test.add",
ADS_AIS_SERVER,
"User1",
"foobar",
ADS_DEFAULT,
&hConnect );

3. Specify a drive letter in the connection string. The drive letter can be specified as <x:>\Dir\DataDictionary.add, where the <x:> is the name of a drive letter specified in the ADS.INI file. The ADS.INI file directly or indirectly specifies the actual IP address where the Advantage Database Server is located, as well as the IP port that the Advantage Database Server is listening, that correspond to the specified drive letter. See Setting Up Your Clients Using ADS.INI for more specifics on information in the ADS.INI file.

Example of using a drive letter with the Advantage Client Engine API:

ulRetVal = AdsConnect60( "x:\\test.add",
ADS_AIS_SERVER,
"User1",
"foobar",
ADS_DEFAULT,
&hConnect );

The Advantage Internet Server configuration can be specified in the ADS.INI file by adding a couple of sections.
The [Drives] section lists the complete UNC path to which a drive letter is mapped. If your client application uses drive letters, you will need to define the drive letter mappings.
Example:

[ Drives ]
R:=\\SERVER1\SHARE

For each Advantage Database Server you want to connect to, you will need to have a separate server-name entry.
Example:

[ <server name> ]
INTERNET_PORT=<the Internet port for the server>
INTERNET_IP=<the IP address for the Advantage Database Server>

Example:

[Drives]
Q:=\\serverA\testsys\
r:=\\serverB\data\
[serverA]
INTERNET_PORT=2001
INTERNET_IP=198.169.1.69
[serverB]
INTERNET_PORT=2002
INTERNET_IP=198.70.169.72


Taken from the ADS help file, finally, when you open the database with the USE command, use the network drive, must be the same that setup in the ini file

Regards
Edmundo
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: expert of ADS and Harbour
Posted: Mon Mar 26, 2012 06:19 PM
Thanks for reply.

Edmundo, did you try yourself?.


Carlos, some commands work other not.


I am able to create a free table with dbcreate():


i := dbCreate( ("\\194.224.200.2:2400\lucas\newtable"),{ { "FNUMERO" ,
"N", 20, 0 }, ;
{ "FCODIGO" , "C", 20, 0 }, ;
{ "FPARCIAL2" , "N", 24, 10 } } )


Also, I am able to delete a file:


AdsDeleteFile("C:\LUCAS\ALBARAN1.DBF") or
or AdsDeleteFile("\\194.224.200.2:2400\LUCAS\ALBARAN1") works too.


But I can麓t open the table in AIS as:

USE "C:\LUCAS\ALBARAN1" or USE "\\194.224.200.2:2400\LUCAS\ALBARAN1" or dbusearea()


In both cases, I get:

Error ADSCDX/5132 The specified database object name is not valid.: C:
\LUCAS\ALBARAN1.DBF


At sybase forums, they said it is possible to use free tables via AIS.


In this post, Rene Flores says it is a bug and it worked as I pretend
in previous xHarbour builds (with xharbour 0.99.3 and previous):
viewtopic.php?f=6&t=6819




This is a full working sample:

Code (fw): Select all Collapse
#include "ads.ch" 
#define CRLF Chr(13)+Chr(10) 


Request ADS,ADSKeyCount,ADSKeyNo,OrdKeyCount,OrdKeyNo, 
AdsGetRelKeyPos, AdsSetRelKeyPos 


//-------------------------------------------------------------------------颅---//
 

function Main() 


     local aArray := {}, cDbf, i 


     RddRegister( "ADS", 1 ) 
     RddSetDefault( "ADS" ) 


     //setting up server type 
     // 1 = Local Server (no client / server) 
     // 2 = Remote Server 
     // 3 = Local + Remot 
     // 4 = Internet Server 
     // 5 = Local + Internet 
     // 6 = Remote+Internet 
     // 7 = Local + Remote + Internet , best choice 
     adsSetServerType( 4 )  // 贸 
adsSetServerType( ADS_REMOTE_SERVER ) 


     //setting up the file types 
     // 1 = DBFNTX 
     // 2 = DBFCDX 
     // 3 = ADSADI 
     adsSetFileType( ADS_CDX ) 


     AdsRightsCheck(.F.) 


   IF AdsConnect60( "\\194.224.200.2:2400\lucas\lucas.ADD", 
4 ,"massimo","") 


   //    MsgInfo("Esta ahora conectado al Sevidor AIS "+CRLF+CRLF+; 
    //     "You are now connected to AIS Server","Bienvenido / 
Welcome / Versi贸n "+ADSVersion()) 


   ELSE 


      alert("Se ha rechazado la conexi贸n al servidor AIS, por favor 
intente mas tarde"+CRLF+CRLF+; 
         "Conection to AIS Server rejected, please, try again later") 


      alert( "Error:"+cValtochar( AdsGetLastError() )+CRLF +; 
            "Servidor:", "Usuario" ) 
      QUIT 


   ENDIF 


   i :=  dbCreate( ("\\194.224.200.2:2400\LUCAS\MASSIMO"), 
{ { "FNUMERO"   , "N", 20, 0 }, ; 
                                   { "FCODIGO"   , "C", 20, 0 }, ; 
                                   { "FPARCIAL2" , "N", 24, 10 } } ) 


   Alert(i)   // I GET .T. 


   use \\194.224.200.2:2400\LUCAS\MASSIMO.DBF new 
   // i get ADSCDX/5132  The specified database object name is not 
valid.: \\194.224.200.2:2400\LUCAS\MASSIMO 


   browse() 


   alert(AdsDeleteFile("\\194.224.200.2:2400\LUCAS\MASSIMO.dbf") )  // 
I GET .T. 


   alert(AdsDeleteFile("c:\lucas\oterfile.dbf") )  // I GET .T. 


   dbcloseall() 
   quit 


return nil




So the behaviour of ADSRDD is inconsistent.


Best regards,
Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: expert of ADS and Harbour
Posted: Tue Mar 27, 2012 01:40 PM

Lucas,

yes, you can't use AIS with free tables.

How you want to configure the 'The security level' without a database (Advantage Data Dictionary), so CATCH 21 :(

So, if you still want to use free tables via Internet, set up a VPN infrastructure and use ADS!

Windows 11 Pro 22H2 22621.1848

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

Harbour 3.2.0dev (r2008190002)

FWH 23.10 x86
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: expert of ADS and Harbour
Posted: Tue Mar 27, 2012 06:16 PM

lucas me interesa contactar contigo,

mi email es donboscocorp2@hotmail.com

salu2
carlos vargas

Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: expert of ADS and Harbour
Posted: Tue Mar 27, 2012 07:35 PM

Frank,

Thank you. Your idea works ;).

I am having trouble with indexes and Data Dictorionary. I create the indexes as INDEX ON FIELD TO INDEXNAME but AIS ignores that.

I think working with a Data Dictionary you need to reindex using AdsReindex(), not INDEX ON command... I麓m not sure,

Carlos, I sent you an email.

Thank you very much.

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: expert of ADS and Harbour
Posted: Tue Mar 27, 2012 09:23 PM

EXECUTE PROCEDURE sp_CreateIndex90(
'caja',
'caja.adi',
'NUM_CIUD',
'num_ciud',
'',
2,
512,
'' );

Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: expert of ADS and Harbour
Posted: Mon Apr 02, 2012 05:37 PM

Thank you, but I need to create the indexes on .prg side, not ARC.

I also need several indexes.

This code works perfect in ADS remote, local or DBCDX but not in AIS:

     // Todas las series
     INDEX ON FSERIE + StrZero (FNUMERO,20 ) TO (cMyPath+&quot;FACTUR1&quot;) FOR !Deleted()
     // Serie A, B 
     INDEX ON FSERIE + StrZero (FNUMERO,20 ) TO (cMyPath+&quot;FACTURA&quot;) FOR (FSERIE=&quot;A&quot;) .AND. !Deleted()
     INDEX ON FSERIE + StrZero (FNUMERO,20 ) TO (cMyPath+&quot;FACTURB&quot;) FOR (FSERIE=&quot;B&quot;) .AND. !Deleted()
     // Cobrada
     INDEX ON FSERIE + StrZero (FNUMERO,20 ) TO (cMyPath+&quot;FACTURC&quot;) FOR FCOBRADA=&quot;S&quot;   .AND. !Deleted()
     INDEX ON FSERIE + StrZero (FNUMERO,20 ) TO (cMyPath+&quot;FACTURN&quot;) FOR FCOBRADA!=&quot;S&quot;  .AND. !Deleted()
     DbCloseAll()

Any clude, Thank you very much,

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: expert of ADS and Harbour
Posted: Tue Apr 03, 2012 12:21 AM
Dear Lucas,

If you are using ADS all-the-way, you might as well consider the SQL related functions in creating your indexes..

Create a function to pass parameter similar to this:

Code (fw): Select all Collapse
cSQL := "CREATE INDEX index1 ON table1 ( field1 ); " 聽 聽 聽 聽 聽 + CRLF +;
聽聽 聽 聽 "CREATE INDEX index2 ON table1 ( field2, field3 ); "
...
IF AdsCreateSQLStatement( cAlias, ADS_ADT, hADSConnection )
聽 聽IF (lOK := ADSExecuteSQLDirect( cSQL ) )
聽 聽 聽 聽...
聽 聽ENDIF
ENDIF
...


just my two cents.. and dont forget to set AUTOOPEN and AUTORDER to .T....
Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: expert of ADS and Harbour
Posted: Tue Apr 03, 2012 08:02 AM
Helo Frances,

Thank you very much for all your help.

The problem is the conditions on the indexes:

Code (fw): Select all Collapse
 // Todas las series
         INDEX ON FIELD->FSERIE + StrZero (FIELD->FNUMERO,20 ) TO FACTUR1 FOR !Deleted()

         // Serie A, B y R
         INDEX ON FIELD->FSERIE + StrZero (FIELD->FNUMERO,20 ) TO FACTUR2 FOR FIELD->FSERIE="A" .AND. !Deleted()
         INDEX ON FIELD->FSERIE + StrZero (FIELD->FNUMERO,20 ) TO FACTUR3 FOR FIELD->FSERIE="B" .AND. !Deleted()
         INDEX ON FIELD->FSERIE + StrZero (FIELD->FNUMERO,20 ) TO FACTUR4 FOR FIELD->FSERIE="R" .AND. !Deleted()
         // Cobrada
         INDEX ON FIELD->FSERIE + StrZero (FIELD->FNUMERO,20 ) TO FACTUR5 FOR FIELD->FCOBRADA="S"   .AND. !Deleted()
         INDEX ON FIELD->FSERIE + StrZero (FIELD->FNUMERO,20 ) TO FACTUR6 FOR FIELD->FCOBRADA!="S"  .AND. !Deleted()
         DbCloseAll()



Indexes are created. But they are not added in my order (FACTUR1, FACTUR2, ..). They are in a different order (2,6,4...):
http://imageshack.us/photo/my-images/189/errorads.png/


I also tried with no luck:
msgalert(AdsDDaddTable("FACTUR1", ".\idx\FACTUR1", "FACTUR1;FACTUR2;FACTUR3;FACTUR4;FACTUR5;FACTUR6" )) //, ".\idx\factur1;.\idx\factura"), "add table")

The order is still different, not FACTUR1, FACTUR2,....


So I don麓t know what is wrong.
Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.

Continue the discussion