home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / msql / test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-04  |  748 b   |  38 lines

  1. #include <exec/types.h>
  2. #include <proto/exec.h>
  3. #include <pragmas/msql_pragmas.h>
  4. #include <proto/msql.h>
  5. #include <libraries/msql.h>
  6. #include <stdio.h>
  7.  
  8. struct Library *MsqlBase;
  9.  
  10. main()
  11. {
  12.     struct MsqlConnection *co;
  13.     m_result *mre;
  14.     m_row    mro;
  15.     if(MsqlBase = OpenLibrary("msql.library", 1))
  16.     {
  17.         if(co = MsqlAllocConnection())
  18.         {
  19.             if(MsqlConnect(co, "localhost"))
  20.             {
  21.                 mre = MsqlListDBs(co);
  22.                 if(mre)
  23.                 {
  24.                     printf("DB(s):\n");
  25.                     while(mro = MsqlFetchRow(co, mre))
  26.                     {
  27.                         printf("%s\n", *mro);
  28.                     }
  29.                     MsqlFreeResult(co, mre);
  30.                 } else printf("ListDBs failed\n");
  31.                 MsqlClose(co);
  32.             } else printf("Connection failed\n");
  33.             MsqlFreeConnection(co);
  34.         } else printf("Alloc failed\n");
  35.         CloseLibrary(MsqlBase);
  36.     }
  37. }
  38.