home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 6 / 06.iso / a / a600 / 5.ddi / SQLCLF.C / SQLCLF.C
Encoding:
C/C++ Source or Header  |  1990-04-23  |  1.7 KB  |  70 lines

  1. /*----------------------------------------------------------------*/
  2. /*                                  */
  3. /*  Example of sqlclf() : Change server activity log file      */
  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.       SQLTRCD   rcd;        /* return code          */
  18.   
  19. main()
  20. {
  21.       SQLTSVH shandle;
  22.           SQLTDAP srvname;
  23.       char    *password;
  24.       char    *logfile;
  25.       int      startflag;
  26.           
  27.    srvname = "SERVER1";
  28.    password = 0;
  29.    startflag = 1;
  30.    logfile = "ACTIVITY.LOG";
  31.    
  32.   /* CONNECT TO THE SERVER  */
  33.  
  34.   if (rcd = sqlcsv(&shandle,srvname,password))
  35.     apierr("SQLCSV");
  36.   else
  37.     printf("Connection Established to Server \n");
  38.  
  39.   /* Changing activity log file */
  40.  
  41.   printf("change activity log file to %s\n", logfile);
  42.   if (rcd = sqlclf(shandle,logfile,startflag))
  43.     apierr("SQLCLF");
  44.   else 
  45.     printf("Successful change and start of server activity log file\n");
  46.         
  47.   /* DISCONNECT FROM THE SERVER */
  48.  
  49.   if (rcd = sqldsv(shandle))
  50.     apierr("SQLDSV");
  51.   else
  52.     printf("Disconnected from Server \n");
  53. }
  54.  
  55. /*
  56.   ERROR - prints an error message for the utility
  57. */
  58.       error(what, line, type)
  59.       char*     what;        /* description of what happened     */
  60.       int        line;        /* line number where error occured  */
  61.       int        type;        /* type of error            */
  62.   {
  63.       char        msg[200];        /* error message buffer         */
  64.  
  65.       sqlerr(rcd, msg);           /* get the error message        */
  66.       printf("\nError: %s at line %d: %s, Error # %d\n", what, line, msg,rcd);
  67.   }
  68.  
  69.  
  70.