home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 6 / 06.iso / a / a600 / 5.ddi / SQLCRE.C / SQLCRE.C
Encoding:
C/C++ Source or Header  |  1990-03-02  |  1.5 KB  |  64 lines

  1. /*----------------------------------------------------------------*/
  2. /*                                  */
  3. /*  Example of sqlcre() : Create Database              */
  4. /*                                  */
  5. /*----------------------------------------------------------------*/
  6.  
  7. #include "stdio.h"
  8. #include "sql.h"
  9. #include "errsql.h"
  10. #include "sqlsrv.h"
  11.  
  12. /* error defines */
  13. #define APIERROR    1
  14.  
  15. #define apierr(a) error(a,__LINE__, APIERROR)
  16.  
  17.       SQLTSVH handle;
  18.           SQLTDAP srvname;
  19.       char *password;
  20.       SQLTRCD   rcd;        /* return code          */
  21.   
  22. main()
  23. {
  24.    srvname = "SERVER1";
  25.    password = 0;
  26.  
  27.   /* CONNECT TO THE SERVER  */
  28.  
  29.   if (rcd = sqlcsv(&handle,srvname,password))
  30.           apierr("SQLCSV");
  31.   else
  32.           printf("Connection Established to Server \n");
  33.   
  34.   /* CREATE DATABASE */
  35.   
  36.   if (rcd = sqlcre(handle,"DEMOX",0))
  37.           apierr("SQLCRE");
  38.   else
  39.           printf("Database DEMOX Created \n");
  40.       
  41.   /* DISCONNECT FROM THE SERVER */
  42.  
  43.   if (rcd = sqldsv(handle))
  44.           apierr("SQLDSV");
  45.   else
  46.           printf("Disconnected from Server \n");
  47. }
  48.  
  49. /*
  50.   ERROR - prints an error message for the utility
  51. */
  52.       error(what, line, type)
  53.       char*     what;        /* description of what happened     */
  54.       int        line;        /* line number where error occured  */
  55.       int        type;        /* type of error            */
  56.   {
  57.       char        msg[200];        /* error message buffer         */
  58.  
  59.       sqlerr(rcd, msg);           /* get the error message        */
  60.       printf("\nError: %s at line %d: %s, Error # %d\n", what, line, msg,rcd);
  61.   }
  62.  
  63.  
  64.