Hi i've got a problem. I keep getting this awesome error "[Build Error] [Project1.exe] Error 1"
I copied this source code from http://www.daniweb.com/forums/thread56924.html
I just can't seem to get it to work. can someone pls help
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <odbcinst.h>
#include <sql.h>
#include <sqlext.h>
#include <sqltypes.h>
int main()
{
SQLHENV env;
SQLHDBC dbc;
SQLHSTMT stmt;
SQLRETURN ret; /* ODBC API return status */
SQLSMALLINT columns; /* number of columns in result-set */
int row = 0;
/* Allocate an environment handle */
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
/* We want ODBC 3 support */
SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
/* Allocate a connection handle */
SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
/* Connect to the DSN mydsn */
/* You will need to change mydsn to one you have created and tested */
SQLDriverConnect(dbc, NULL, (SQLTCHAR FAR *)"DSN=shruthiks;", SQL_NTS,
NULL, 0, NULL, SQL_DRIVER_COMPLETE);
/* Allocate a statement handle */
SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
/* Retrieve a list of tables */
SQLTables(stmt, NULL, 0, NULL, 0, NULL, 0, (SQLTCHAR FAR *)"TABLE", SQL_NTS);
/* How many columns are there */
SQLNumResultCols(stmt, &columns);
/* Loop through the rows in the result-set */
while (SQL_SUCCEEDED(ret = SQLFetch(stmt)))
{
SQLUSMALLINT i;
printf("Row %d\n", row++);
/* Loop through the columns */
for (i = 1; i <= columns; i++)
{
SQLINTEGER indicator;
char buf[512];
/* retrieve column data as a string */
ret = SQLGetData(stmt, i, SQL_C_CHAR,buf, sizeof(buf), &indicator);
if (SQL_SUCCEEDED(ret))
{
/* Handle null columns */
if (indicator == SQL_NULL_DATA)
strcpy(buf, "NULL");
printf(" Column %u : %s\n", i, buf);
}
}
}
system("PAUSE");
return 0;
}
Also linked the project with
lib/libodbc32.a
lib/libodbccp32.a