【问题标题】:Get an unsorted recordset from ADO从 ADO 获取未排序的记录集
【发布时间】:2014-10-07 23:12:04
【问题描述】:

我正在使用 ADO 从 excel 文件中获取表头列名。问题是返回的数据是排序的。我需要它的原始顺序。这是代码:

_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();
}

我怎样才能让它返回未排序?

【问题讨论】:

    标签: c++ excel ado


    【解决方案1】:
    int ordinalPosition = (int)pSchema->Fields->GetItem("ORDINAL_POSITION")->Value.dblVal;
    

    然后按 ordinalPosition 排序(从索引 1 开始)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多