by R.F. » Sat Apr 21, 2007 6:57 pm
Ramesh:
In the SQL-based databases, all the stuff is stored in one single file, for example in MS Access all the tables, users, passwords, security schemas,stored procedures, etc is stored into a one singe MDB file, same happens in SQL Server, MySQL, Informix, etc.
ADS tries to do the same, using a "data dictionary" with a "little" difference, the DBF or ADT tables will not be "merge" into one single file, in this case the file is the data dictionary, they will remain as "free files", but they will be handled by the Data Dictionary, because the DD will have an internal reference to them.
How to create a dictionary:
To create the data dictionary you need to use the ARC, open the ARC (Advantage Data Architech), go to DATABASE in the main menu and select NEW DATABASE, give it a name, check the appropiate features you may need, and you are done.
The DD creation is also available via SourceCode in (x)Harbour.
Inmediatly after creating the dictionary you will need to create a "super user account" this is an administrative user account, by default ADS will create the ADSSYS user, and you will have to give it a password.
Data dictionaries will have the .ADD extension.
Once created, you will need to add all the tables you want to be accesed via the data dictionary, remember, the tables will not be merged into the DD, this is only to give the DD a reference of where are those tables located; this gives you an extra level or security because you will need a user and password to access the data.
To add tables into the dictionary, go to the tree structure you will see at the left of the screen, select TABLES, right click over the TABLES item, and you will see a pop up menu, select ADD EXISTING TABLES, then pick up all the tables and indexes you will need to be into the data dictionary and you are done. Tables can be DBF with CDX or NTX indexes and DBT or FPT memos, or ADT tables with ADI indexes and ADM memos, you can also mix ADTs and DBFs in the same dictionary.
The goal of a data dictionary is to give an extra security level because you need to create users in the dictionary and give permissions to them for reading, writting, or deleting data, in DBF or ADT tables.
Data dictionaries are also important for internet access, because every user you create into the dictionary can have, or not to have Internet access to your data, you can set this feature every time you create a new user or you can modify user accounts to let them read your data via internet.
Thanks to ADS, you can handle data using SQL statements, Data dictionaries are also important to users that have worked with SQL based databases, they are used to "connect" to the database using an administrative program, and after that they can write queries to retrieve data, in ADS you can also "connect" o a database, this "database" is called "data dictionary" and, as a Data Dictionary has a list of all the tables needed, you can handle them as in the most popular SQL based systems.
So far so good, let's see now how to use the DD in (x)Harbour code.
First you will need to connect to the dictionary, which is the the most important part:
AdsConnect60(<data dict>,<server type>, <user>,<password>)
<data dict> is the route where the DD is, this route has to be indicated using the UNC:
\\server\shared resource\folder\dictionary.add
sample:
\\googleserver\adsdemos\samples\demo.add
This may sound reasonable if we were working into a LAN, but what if we want to use the Internet access to the data.
For internet access (and to speed the lan access too), ADS will use a configuration file that is used by the AXWCS32.DLL (ADS windows client), this file is an INI file called ADS.INI and you have to place it in the same directory where your exe file is.
This INI files has to be a section with the server name:
[googleserver]
under this section you have to put the LAN address of the server AND in case you were working via internet, you have to place the public IP adress or the domain name:
[googleserver]
LAN_IP=192.168.2.1
When working with the REMOTE ADS server (not the local), you also need to configure the ports of the server where you are reading information, this is done using the Advantage Configuration Utility, only available with the remote server, using this tool, you configure the lan ports and internet ports to be used, and in the ADS.INI you have to indicate such ports.
[googleserver]
LAN_IP=192.168.2.1
LAN_PORT=2000
If you are using the AIS (Advantage Internet Server), you will also have to indicate the public IP of the server, or the domain name in order to resolve de ip address, also, you have to indicate which port is "listening" the internet requests:
[googleserver]
LAN_IP=192.168.2.1
LAN_PORT=2000
INTERNET_IP=google.d2g.com ; or 200.67.137.11
INTERNET_PORT = 2001
Please notice that LAN and INTERNET port must be different.
Back to the dictionary connection, the first two parameters will try to connect to the dictionary using the server type stablished.
AdsConnect60("\\googleserver\adsdemos\demo.add",4,.......)
When calling this function, the ADS client will read the UNC, and inmediatly after will look for the ADS.INI looking for the server name section, and using its entries will try to resolve the server location.
The server type (4) is also important, 4 indicates that it must connect to the server only via INTERNET which means that no matter if the computer is connected to the LAN, the programm will attemp to connect to the server via INTERNET using the entries in the INI file. If there's no internet connection available the program will indicate an error, and it will finish.
Values for the connection parameter are:
(1) Local server only, no client server nor transactions features, no internet access either, this is a free redistributable server for developing, testing or for commercial applications, you can use it in a single computer (stand alone) but you can also use it up to 5 users under LAN enviroments, you are free to use and distribute this server (ADSLOC32.DLL).
(2) Remote server only, you need to have an ADS remote server running in your server. Remote server will run under Novell Netware (from version 5.x and greater), Linux or Windows true 32 enviroments (NT, 2000, XP, 2003 or Vista), your choice.
(3) Local (1) + remote servers (2), the program will attempt to connect first via the remote server, if there's no remote server running on the file server, it will use the local server, this value is adecuate if you are planing to move to a remote server later, because avoids you to write double code or to make modifcations into the source, you can work with free local server, and when you decide to move into the remote server for all the client/server transactional features, you will not need to make any changes to your code, simply install the remote server, and run your program again.
(4) Internet server. This configuration is adecuate for remote computers, not connected to the LAN, using internet to gain access to the data.
(5) Local (1) + Internet (4), you can use both servers, local and internet, for example, you can use the internet access to retrieve data via internet, and use the local server to create temp data files for reporting in your local computer.
(6) Remote (2) + Internet (4), you can use this value when are working in your office in your LAN, retrieving data from the server, and if you go out of the office in a trip or want to work at home, you can use internet to connect to the server, remember, no modifications in the source code are needed, the same exe will work under the lan an under internet.
(7) Local (1) + Remote (2) + Internet (4), this is your best choice since it allows you to connect to any server or combination of servers, for example you are working at your office in your LAN, using the remote server (2), but you go out of the office and decide to work at home, you can use the same exe to connect to a internet server (4), and you can use the local server (1) to create temp DBF or ADT files in your local hd for reporting.
And finally, the last two parameters of the AdsConnect60() function are the user name, and its password, these values are set in the data dictionary when creating a new user.
Saludos
R.F.