home *** CD-ROM | disk | FTP | other *** search
- /*----------------------------------------------------------------*/
- /* */
- /* Example of sqlcre() : Create Database */
- /* */
- /*----------------------------------------------------------------*/
-
- #include "stdio.h"
- #include "sql.h"
- #include "errsql.h"
- #include "sqlsrv.h"
-
- /* error defines */
- #define APIERROR 1
-
- #define apierr(a) error(a,__LINE__, APIERROR)
-
- SQLTSVH handle;
- SQLTDAP srvname;
- char *password;
- SQLTRCD rcd; /* return code */
-
- main()
- {
- srvname = "SERVER1";
- password = 0;
-
- /* CONNECT TO THE SERVER */
-
- if (rcd = sqlcsv(&handle,srvname,password))
- apierr("SQLCSV");
- else
- printf("Connection Established to Server \n");
-
- /* CREATE DATABASE */
-
- if (rcd = sqlcre(handle,"DEMOX",0))
- apierr("SQLCRE");
- else
- printf("Database DEMOX Created \n");
-
- /* DISCONNECT FROM THE SERVER */
-
- if (rcd = sqldsv(handle))
- apierr("SQLDSV");
- else
- printf("Disconnected from Server \n");
- }
-
- /*
- ERROR - prints an error message for the utility
- */
- error(what, line, type)
- char* what; /* description of what happened */
- int line; /* line number where error occured */
- int type; /* type of error */
- {
- char msg[200]; /* error message buffer */
-
- sqlerr(rcd, msg); /* get the error message */
- printf("\nError: %s at line %d: %s, Error # %d\n", what, line, msg,rcd);
- }
-
-
-