priya6122003
April 10th, 2006, 06:10 AM
Following is simple connection demo.I using VC++ 8.0 ( windows server 2003 )to compile and getting lots of compilation errors.
could anybody please help me with this.
sample of the errors are :
:\program files\microsoft visual studio 8\vc\platformsdk\include\sqltypes.h(149) : error C2054: expected '(' to follow 'SQLHWND'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\sqltypes.h(153) : error C2085: 'DATE_STRUCT' : not in formal parameter list
c:\program files\microsoft visual studio 8\vc\platformsdk\include\sqltypes.h(156) : error C2085: 'DATE_STRUCT' : not in formal parameter list
c:\program files\microsoft visual studio 8\vc\platformsdk\include\sqltypes.h(156) : error C2146: syntax error : missing ',' before identifier 'SQL_DATE_STRUCT'
this is the seemingly harmless code :
#include <windows.h>
#include <sqlext.h>
#include <sql.h>
#include <stdio.h>
main()
{
SQLHENV henv;
SQLHDBC hdbc;
SQLHSTMT hstmt;
SQLRETURN retcode;
/*Allocate environment handle */
retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
/* Set the ODBC version environment attribute */
retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
/* Allocate connection handle */
retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
/* Set login timeout to 5 seconds. */
SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (void*)5, 0);
/* Connect to data source */
retcode = SQLConnect(hdbc, (SQLWCHAR*) "Sales", SQL_NTS,
(SQLWCHAR*) "JohnS", SQL_NTS,
(SQLWCHAR*) "Sesame", SQL_NTS);
/* Allocate statement handle */
retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
/* Process data */
;
;
;
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
}
SQLDisconnect(hdbc);
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
SQLFreeHandle(SQL_HANDLE_ENV, henv);
}
Thankz
could anybody please help me with this.
sample of the errors are :
:\program files\microsoft visual studio 8\vc\platformsdk\include\sqltypes.h(149) : error C2054: expected '(' to follow 'SQLHWND'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\sqltypes.h(153) : error C2085: 'DATE_STRUCT' : not in formal parameter list
c:\program files\microsoft visual studio 8\vc\platformsdk\include\sqltypes.h(156) : error C2085: 'DATE_STRUCT' : not in formal parameter list
c:\program files\microsoft visual studio 8\vc\platformsdk\include\sqltypes.h(156) : error C2146: syntax error : missing ',' before identifier 'SQL_DATE_STRUCT'
this is the seemingly harmless code :
#include <windows.h>
#include <sqlext.h>
#include <sql.h>
#include <stdio.h>
main()
{
SQLHENV henv;
SQLHDBC hdbc;
SQLHSTMT hstmt;
SQLRETURN retcode;
/*Allocate environment handle */
retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
/* Set the ODBC version environment attribute */
retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
/* Allocate connection handle */
retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
/* Set login timeout to 5 seconds. */
SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (void*)5, 0);
/* Connect to data source */
retcode = SQLConnect(hdbc, (SQLWCHAR*) "Sales", SQL_NTS,
(SQLWCHAR*) "JohnS", SQL_NTS,
(SQLWCHAR*) "Sesame", SQL_NTS);
/* Allocate statement handle */
retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
/* Process data */
;
;
;
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
}
SQLDisconnect(hdbc);
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
SQLFreeHandle(SQL_HANDLE_ENV, henv);
}
Thankz