home *** CD-ROM | disk | FTP | other *** search
/ WinWares 1 / WINWARES.ISO / database / gupta / sqlfgt.c / sqlfgt.c
Encoding:
C/C++ Source or Header  |  1993-12-11  |  1.8 KB  |  75 lines

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