Question:
ADO 里面怎么获得 SQL sum 函数返回的值
#define QUERY _T( "SELECT count(*) from test WHERE MACHINENAME = 'TEST ' ")
g_Rst-> Open(_variant_t(QUERY),g_Conn.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText);
long lUbound = g_Rst-> GetRecordCount();
结果发现 lUbound 返回的是-1
_variant_t vCount = g_Rst-> GetCollect(_variant_t((long)0));
也得不到sql sum返回的内容
没想明白怎么回事
同样的查询语句可以在SQL企业管理器里面正常使用
Answer:
SELECT sum(number) AS numCount from test WHERE MACHINENAME = 'TEST '
注意:AS numCount,在程序中取这个列( numCount )的值就可以。