home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <proto/exec.h>
- #include <pragmas/msql_pragmas.h>
- #include <proto/msql.h>
- #include <libraries/msql.h>
- #include <stdio.h>
-
- struct Library *MsqlBase;
-
- main()
- {
- struct MsqlConnection *co;
- m_result *mre;
- m_row mro;
- if(MsqlBase = OpenLibrary("msql.library", 1))
- {
- if(co = MsqlAllocConnection())
- {
- if(MsqlConnect(co, "localhost"))
- {
- mre = MsqlListDBs(co);
- if(mre)
- {
- printf("DB(s):\n");
- while(mro = MsqlFetchRow(co, mre))
- {
- printf("%s\n", *mro);
- }
- MsqlFreeResult(co, mre);
- } else printf("ListDBs failed\n");
- MsqlClose(co);
- } else printf("Connection failed\n");
- MsqlFreeConnection(co);
- } else printf("Alloc failed\n");
- CloseLibrary(MsqlBase);
- }
- }
-