Getting Error 'EXEC' : undeclared identifier
I am trying to compile code below in Microsoft visual c++.
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fstream>
using std::ifstream;
using std::ofstream;
#include <iostream>
using std::ios;
using std::cout;
using std::endl;
/* DB2 ODBC Header */
#include <sqlenv.h>
#include <sqlca.h>
int main ()
{
char dbname[15] ;
char user[128 + 1] ;
char pswd[15] ;
strcpy (dbname, "DB2HNB1");
strcpy (user, "STORBIT");
strcpy (pswd, "TOUCHP2");
EXEC SQL CONNECT TO :dbname USER :user USING :pswd;
if (SQLCODE != 0) {
printf ("\n *** Error ***\n");
exit (0);
}
else {
printf ("\n Successful connection to '%s' db using C
embedded static SQL\n",dbname);
}
return 0;
}
I can not figure out why I am getting this error:
:\db2odbcproject3\db2odbcproject3.cpp(37) : error C2065: 'EXEC' : undeclared identifier
C:\db2odbcproject3\db2odbcproject3.cpp(37) : error C2146: syntax error : missing ';' before identifier 'SQL'
C:\db2odbcproject3\db2odbcproject3.cpp(37) : error C2065: 'SQL' : undeclared identifier
C:\db2odbcproject3\db2odbcproject3.cpp(37) : error C2146: syntax error : missing ';' before identifier 'CONNECT'
C:\db2odbcproject3\db2odbcproject3.cpp(37) : error C2065: 'CONNECT' : undeclared identifier
C:\db2odbcproject3\db2odbcproject3.cpp(37) : error C2146: syntax error : missing ';' before identifier 'TO'
C:\db2odbcproject3\db2odbcproject3.cpp(37) : error C2146: syntax error : missing ';' before identifier 'USER'
C:\db2odbcproject3\db2odbcproject3.cpp(37) : error C2146: syntax error : missing ';' before identifier 'USING'
Error executing cl.exe.
Please help..
|