#include "mytest3.h" /* MyODBC 3.51 sample utility header */ #define NAME_LEN 50 #define PHONE_LEN 50 void bug16259(SQLHSTMT hstmt) { SQLINTEGER i, count; SQLRETURN retcode; retcode = SQLExecDirect(hstmt, "SELECT id from test.bug16259", SQL_NTS); if (retcode == SQL_SUCCESS) { while (TRUE) { retcode = SQLFetch(hstmt); if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO){ SQLGetData(hstmt, 1, SQL_C_SLONG, &i, sizeof(int), &count); printf("%d\n", i); } else { break; } } } } void createEnvironment(SQLHSTMT hstmt) { SQLExecDirect(hstmt, "DROP TABLE IF EXISTS test.bug16259", SQL_NTS); SQLExecDirect(hstmt, "CREATE TABLE test.bug16259(id int)", SQL_NTS); SQLExecDirect(hstmt, "INSERT INTO test.bug16259 VALUES (1), (2), (3), (4), (5), (6), (7)", SQL_NTS); } void cleanEnvironment(SQLHSTMT hstmt) { SQLExecDirect(hstmt, "DROP TABLE test.bug16259", SQL_NTS); } int main(int argc, char *argv[]) { SQLHENV henv; SQLHDBC hdbc; SQLHSTMT hstmt; SQLINTEGER narg; printMessageHeader(); /* * if connection string supplied through arguments, overrite * the default one.. */ for (narg = 1; narg < argc; narg++) { if ( narg == 1 ) mydsn = argv[1]; else if ( narg == 2 ) myuid = argv[2]; else if ( narg == 3 ) mypwd = argv[3]; } /* * connect to MySQL server */ myconnect(&henv,&hdbc,&hstmt); createEnvironment(hstmt); bug16259(hstmt); cleanEnvironment(hstmt); printMessageFooter(1); return(0); //cl -I../include -I. /G5 -DWINDOWS -DWIN32 -o3 /nologo bug16259.c C:\WINDOWS\system32\myodbc3.lib -obug16259.exe }