Курсовая работа: Visual C++. Бази даних Укр.
SQLTRY(«SQLBindCol», SQLBindCol(hStmt, 3, SQL_C_SLONG, (PTR)&nRating, sizeof(nRating), &sdwRLen))
SQLTRY(«SQLExecute», SQLExecute(hStmt))
for (i = 1; (rc = SQLFetch(hStmt)) == SQL_SUCCESS; i++)
{
printf(«Record #%d\tName: %s\tFaculty: %s\tRating: %d\n», i, szName, szFaculty, nRating);
}
if (rc != SQL_NO_DATA_FOUND)
{
SQLTRY(«SQLFetch», rc)
}
printf(«Successfully completed.\n»);
Terminate0:
if (hStmt) SQLFreeStmt(hStmt, SQL_CLOSE);
if (hDBC) SQLDisconnect(hDBC);
if (hDBC) SQLFreeConnect(hDBC);
if (hEnv) SQLFreeEnv(hEnv);
SQLTRY(«SQLAllocEnv», SQLAllocEnv(&hEnv))
SQLTRY(«SQLAllocConnect», SQLAllocConnect(hEnv, &hDBC))
SQLTRY(«SQLDriverConnect», SQLDriverConnect(hDBC, NULL, CONNSTR, CONNLEN, szConnStr, sizeof(szConnStr), &cbConnStr, SQL_DRIVER_NOPROMPT))
SQLTRY(«SQLAllocStmt», SQLAllocStmt(hDBC, &hStmt))
sprintf(szStmt, «SELECT * FROM [Sheet1$] WHERE Rating>91 ORDER BY Rating DESC»);
SQLTRY(«SQLPrepare», SQLPrepare(hStmt, szStmt, strlen(szStmt)))
SQLTRY(«SQLBindCol», SQLBindCol(hStmt, 1, SQL_C_CHAR, (PTR)szName, sizeof(szName), &sdwNLen))
SQLTRY(«SQLBindCol», SQLBindCol(hStmt, 2, SQL_C_CHAR, (PTR)szFaculty, sizeof(szFaculty), &sdwFLen))
SQLTRY(«SQLBindCol», SQLBindCol(hStmt, 3, SQL_C_SLONG, (PTR)&nRating, sizeof(nRating), &sdwRLen))
SQLTRY(«SQLExecute», SQLExecute(hStmt))
for (i = 1; (rc = SQLFetch(hStmt)) == SQL_SUCCESS; i++)
{
printf(«Record #%d\tName: %s\tFaculty: %s\tRating: %d\n», i, szName, szFaculty, nRating);