Your code is not printing the value of the first row but the same random value for each row.
Your query specifies a single column only. So you can only get data for column one but you are asking for column 2. You would have noticed this when checking the
GetData()
return value.
So try this:
SQLRETURN ret = SQLGetData(hstmt, 1, SQL_CHAR, sqlVersion, sizeof(sqlVersion), &ptrSqlVersion);