ADO GetCollect取不到CASE WHEN END的数据怎么解决?
ADO连接SQLServer数据库SQL如下:
_bstr_t bstrSql("");
bstrSql += "SELECT Name = C.name, ";
bstrSql += "SORT = Case INDEXKEY_PROPERTY(IDXC.[object_id],IDXC.index_id,IDXC.index_column_id,'IsDescending') ";
bstrSql += "WHEN 1 THEN 'DESC' WHEN 0 THEN 'ASC' ELSE ' ' END ";
bstrSql += "FROM " + m_strDbName + ".sys.indexes IDX ";
bstrSql += "INNER JOIN " + m_strDbName + ".sys.index_columns IDXC ";
bstrSql += "ON IDX.[object_id]=IDXC.[object_id] ";
bstrSql += "AND IDX.index_id=IDXC.index_id ";
bstrSql += "LEFT JOIN " + m_strDbName + ".sys.key_constraints KC ";
bstrSql += "ON IDX.[object_id]=KC.[parent_object_id] ";
bstrSql += "AND IDX.index_id=KC.unique_index_id ";
bstrSql += "INNER JOIN " + m_strDbName + ".sys.objects O ";
bstrSql += "ON O.[object_id]=IDX.[object_id] ";
bstrSql += "INNER JOIN " + m_strDbName + ".sys.columns C ";
bstrSql += "ON O.[object_id]=C.[object_id] ";
bstrSql += "AND O.type='U' ";
bstrSql += "AND O.is_ms_shipped=0 ";
bstrSql += "AND IDXC.Column_id=C.Column_id ";
bstrSql += "WHERE O.name = '" + _bstr_t(LPCTSTR(strTblName)) + "' ";
bstrSql += "ORDER BY IDXC.index_id ";
使用pRrdset->GetCollect(_variant_t("Name"))
或pRrdset->GetCollect(_variant_t(long(0)))可以取到值,但是
用同样的方法却取不到Sort的值。
pRrdset->GetCollect(_variant_t("SORT"))
或pRrdset->GetCollect(_variant_t(long(1)))
这是怎么回事?是不是因为SORT是CASE WHEN END判断出来的,而不是真正的DB数据?
该怎么解决呢?