0

I'm using ADO to get from excel file the table header column names. The problem is the data is returned sorted. I need it in it's original order. This is the code:

_RecordsetPtr pSchema->m_pCon->OpenSchema(adSchemaColumns);
// pSchema->Sort = ""; // Does not help
// pSchema->Sort = "ORDINAL_POSITION"; // Crashes
while (!pSchema->GetadoEOF()) 
{
    string sheetName = (char*)(_bstr_t)pSchema->Fields->GetItem("TABLE_NAME")->Value.bstrVal;
    if (sheetName == "MySheet")
        string column = (char*)(_bstr_t)pSchema->Fields->GetItem("COLUMN_NAME")->Value.bstrVal;
    pSchema->MoveNext();
}

How can I make it return unsorted?

grunt
  • 662
  • 1
  • 8
  • 24

1 Answers1

0
int ordinalPosition = (int)pSchema->Fields->GetItem("ORDINAL_POSITION")->Value.dblVal;

Then order by ordinalPosition (starts with index 1).

grunt
  • 662
  • 1
  • 8
  • 24