#include <windows.h>
#include <sql.h>
#include <sqlext.h>
void main(void)
{
HENV henv;
HDBC hdbc;
HSTMT hstmt;
SQLRETURN retcode;
retcode = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv);
// We need to set the ODBC version to SQL_OV_ODBC3.
retcode = SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,(void *)SQL_OV_ODBC3,SQL_C_SLONG) ;
retcode = SQLAllocHandle(SQL_HANDLE_DBC,henv, &hdbc);
//Make sure that autocommit is set to ON.
retcode = SQLSetConnectAttr(hdbc,SQL_ATTR_AUTOCOMMIT,(void *)SQL_AUTOCOMMIT_ON,0);
//Change the DSN, user ID, and password accordingly.
retcode = SQLConnect(hdbc, (SQLCHAR*)"DSN NAME",SQL_NTS, (SQLCHAR*) "USER ID",SQL_NTS ,(SQLCHAR*)"PASSWORD",SQL_NTS);
retcode = SQLAllocHandle(SQL_HANDLE_STMT,hdbc, &hstmt);
retcode = SQLPrepare(hstmt,(unsigned char *)"{call TestSP}",SQL_NTS);
retcode = SQLExecute(hstmt);
//Uncomment the following SQLMoreResults call to collect all returned tokens.
//while (retcode != SQL_NO_DATA)
//retcode = SQLMoreResults(hstmt);
retcode = SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
retcode = SQLDisconnect(hdbc);
retcode = SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
retcode = SQLFreeHandle(SQL_HANDLE_ENV, henv);
}