ODBC Samples
------------
1 ODBC Sample Files Purpose
2 How to Run ODBC Samples
3 How to compile an ODBC program in UNIX
4 How to run the ODBC sample programs in UNIX


1 ODBC Sample Files Purpose
---------------------------
    Sample: ex1.c
    Purpose: 
        This sample demostrates how to use ODBC functions to access 
        database.
        1. connect to database
        2. define a permanent table odbc_tb1
        3. insert tuples into table odbc_tb1
        4. define a permanent table odbc_tb2
        5. insert tuples into table odbc_tb2 using paramters 
        6. execute a select command on odbc_tb1
        7. fetch all tuples from table odbc_tb1
        8. execute a select command on odbc_tb2
        9. fetch all tuples from table odbc_tb2
        10. drop tables odbc_tb1 and odbc_tb2
        11. end transaction 
        12. terminate db


2 How to Run ODBC Samples
-------------------------
    Use Visual Studio Project to Build: 
        1. Create visual studio 2022 project.
           Open visual studio 2022 --> Create a new Project, choose C++ Empty Project, Next
           Set Project name and Location, then Create
        2. Add .h and .c.
           Solution'ex1' --> ex1 --> Header files, Add Existing Item C:\DBMaker\5.4\samples\ODBC\ex1.h
           Solution'ex1' --> ex1 --> Source files, Add Existing Item C:\DBMaker\5.4\samples\ODBC\ex1.c
        3. Configuraton Properties.   
           Solution'ex1' --> ex1 --> Properties, Open ex1 Property Pages
           Configuraton Properties --> Advanced --> Character Set:  Use Multi-Byte Character Set
           VC++ Directories --> Include Directories:  C:\DBMaker\5.4\include
           C/C++ --> SDL checks:  no
           Linker --> Input --> Addtional Dependencies:  odbc32.lib
        4. Build --> Build ex1 or Rebuild ex1

    Execute:
        1.Start DBSAMPLE5.
        2.Add ODBC Data Source.
          Open ODBC Data Source Administrator --> System DSN --> Add, choose DBMaker 5.4 Driver.
          Please Set DataBase Name:DBSAMPLE5, Please Test and ok.
        3.Start without Debugging or Ctrl + F5.
        
    Note: 
        You can link dmapi54.lib directly to execute ex1.exe:
        Solution'ex1' --> ex1 --> Properties, Open ex1 Property Pages.
        VC++ Directories --> Library Directories:  C:\DBMaker\5.4\lib
        Linker --> Input --> Addtional Dependencies:  dmapi54.lib 


    Use nmake to build:
        Open cmd with administrator.
        >cd C:\"Program Files\Microsoft Visual Studio"\2022\Community\VC\Auxiliary\Build
        >C:
        >vcvars64.bat
        >cd C:\DBMaker\5.4\samples\ODBC
        >C:
        >nmake -f ex1_64.mak MSVC_VER=1930 WIN64=1
        >cd debug
        >ex1.exe      


3 How to compile an ODBC program in UNIX
----------------------------------------
        1. Check what compiler is provided on your machine, for example
           'cc'.

        2. Set the include path to the 'inlcude' directory under the 
           home directory of the user 'dbmaker' and compile the C 
           program. For example:

              % cc -c -I/APP_HOME/include ex1.c

        3. Set the library path to the 'lib' directory under the home 
           directory of the user 'dbmaker'(/APP_HOME/lib). 

        4. Link libdmapic.a, to make an application that will run in the
           Client-Server environment. For example :

          % cc -o ex1 ex1.o -L/APP_HOME/lib -ldmapic -lm -ldl


4 How to run the ODBC sample programs in UNIX
---------------------------------------------
    Steps:
        1. Start the 'DBSAMPLE5' database in client-server mode.  

        2. Type 'make' command under the shell environment.

           % make

        3. Type 'ex1' command under the shell environment.

           % ./ex1
