本文介绍了从 ADO 获取未排序的记录集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 ADO 从 excel 文件中获取表头列名称.问题是返回的数据是排序的.我需要它的原始顺序.这是代码:
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();
}
如何让它返回未排序?
推荐答案
int ordinalPosition = (int)pSchema->Fields->GetItem("ORDINAL_POSITION")->Value.dblVal;
然后按 ordinalPosition 排序(从索引 1 开始).
Then order by ordinalPosition (starts with index 1).
这篇关于从 ADO 获取未排序的记录集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!