Skip to content

Instantly share code, notes, and snippets.

@sergioceron
Created August 12, 2012 18:16
Show Gist options
  • Save sergioceron/3333539 to your computer and use it in GitHub Desktop.
Save sergioceron/3333539 to your computer and use it in GitHub Desktop.
Get resultset to struct DSN Windows c++
retcode = SQLAllocStmt (hDBC, &hStmt);
retcode = SQLPrepare (hStmt, (UCHAR *)sqls, SQL_NTS);
retcode = SQLExecute (hStmt);
SQLBindCol(hStmt, 3, SQL_C_SLONG, &szModel, 5, &ic);
SQLBindCol(hStmt, 2, SQL_C_CHAR, szModel1, sizeof(szModel1), &cbModel);
SQLBindCol(hStmt, 4, SQL_C_FLOAT, &szModel2, 5, &cbModel);
SQLBindCol(hStmt, 5, SQL_C_FLOAT, &szModel3, 5, &cbModel);
SQLBindCol(hStmt, 6, SQL_C_SLONG, &szModel4, 5, &ic);
SQLBindCol(hStmt, 7, SQL_C_CHAR, szModel5, sizeof(szModel5), &cbModel);
retcode = SQLFetch (hStmt);
int count = -1;
while (retcode == SQL_SUCCESS || retcode ==SQL_SUCCESS_WITH_INFO)
{
count++;
p[count].id=szModel;
strcpy(p[count].nombre,szModel1);
p[count].precio=szModel2;
p[count].descuento=szModel3;
p[count].cantidad=szModel4;
strcpy(p[count].marca,szModel5);
retcode = SQLFetch (hStmt);
}
SQLFreeStmt (hStmt, SQL_DROP);
SQLDisconnect(hDBC);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment