OK, not had much luck lately on other postings, so hopefully I have formatted this to peoples liking....

I am successfully calling a MS SQL SERVER db and getting data from it, however, I want to call all rows and return them one after another, not just the last row.

Been researching using the function SQLFetchScroll and had little success. Returns the last row as well. Below is my code, any help on how to return all the rows fromt he qery would be very much appreciated. Thanks-

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
	int nRetCode = 0;
	HENV                      hEnv = NULL; // Env Handle from SQLAllocEnv()

    HDBC                      hDBC = NULL; // Connection handle

    HSTMT                     hStmt = NULL;// Statement handle

    UCHAR                     szDSN[SQL_MAX_DSN_LENGTH] = "dashboard";// Data Source Name buffer

	UCHAR                     szUID[10] = "dashboard";// User ID buffer 

    UCHAR                     szPasswd[10] = "dashboard";// Password buffer

	RETCODE					  ret;

	SQLCHAR * szSQLStmt = (SQLCHAR*)"Select DateStamp, LabelSku, Weight, Line, ToteStatus From HEBFullToteStatus WHERE Line = 9 Order by DateStamp;"; 

//	ret = SQLPrepare(hStmt, szSQLStmt, SQL_NTS); 

// Allocate memory for ODBC Environment handle

   SQLAllocEnv (&hEnv);

   // Allocate memory for the connection handle

   SQLAllocConnect (hEnv, &hDBC);

   // Connect to the data source "test" using userid and password.

   ret = SQLConnect (hDBC, szDSN, SQL_NTS, szUID, SQL_NTS, szPasswd, SQL_NTS);

   if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)
		cout <<"Connected successfully!"<<endl;
		// Allocate memory for the statement handle

        ret = SQLAllocStmt (hDBC, &hStmt);
		if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)
			cout<<"\n"<<"Memory Allocate Successful!!!"<<endl;
			// Prepare the SQL statement by assigning it to the statement handle

      //      ret = SQLPrepare (hStmt, szSQLStmt, sizeof (szSQLStmt));
			ret = SQLPrepare(hStmt, szSQLStmt, SQL_NTS);
			if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)
				cout<<"\n"<<"SQL Prepare Succeeded!!!"<<endl;
				UCHAR szLine[5];
				UCHAR szStatus[5];
				UCHAR szUserDate[50]; 
				UCHAR szSku[50];
				UCHAR szWeight[25];

				SDWORD cbLine;
				SDWORD cbStatus;
				SDWORD cbUserDate;
				SDWORD cbSku;
				SDWORD cbWeight;

				ret = SQLExecute(hStmt); 

				if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)
					int counter = 0;
					cout <<"SQLExecute Successful"<<endl;

					SQLBindCol (hStmt, 1, SQL_C_CHAR, szUserDate, sizeof(szUserDate), &cbUserDate);
					SQLBindCol (hStmt, 2, SQL_C_CHAR, szSku, sizeof(szSku), &cbSku);
					SQLBindCol (hStmt, 3, SQL_C_CHAR, szWeight, sizeof(szWeight), &cbWeight);
					SQLBindCol (hStmt, 4, SQL_C_CHAR, szLine, sizeof(szLine), &cbLine);
					SQLBindCol (hStmt, 5, SQL_C_CHAR, szStatus, sizeof(szStatus), &cbStatus);
			//		do
			//		{
						ret = SQLFetch (hStmt);
						// Fetch the next rowset
			//			ofstream fout;
			//			fout.open("C:\\TestSQL.txt", ios::app);
						cout <<szUserDate<<endl;
						cout <<szSku<<endl;
						cout <<szWeight<<endl;
						cout <<szLine<<endl;
						cout <<szStatus<<endl;
				//		fout.close();
						// Free the allocated statement 
			//			SQLFreeStmt (hStmt, SQL_DROP);
			//			SQLFetchScroll(hStmt, SQL_FETCH_NEXT, 1);

					cout <<"SQLExecute Failed : - ("<<endl;

				cout<<"\n"<<"Did not successfully Prepare SQL!!!"<<endl;
			cout<<"\n"<<"Did not successfully Allocate Memory!!!"<<endl;

   else if (ret != SQL_SUCCESS || ret != SQL_SUCCESS_WITH_INFO)
	   cout <<"Bummer did not Connect"<<endl;

	return nRetCode;