如何通过ADO使用聚合函数来查询(数据库为ACCESS)
_RecordsetPtr CMyAdo::SelectRecord(string &where, string &tablename,string &field, int way )
{
int ret = 0;
_RecordsetPtr pset;
CString sql;
VARIANT count;
count.vt = VT_INT;
ret = OpenDB();
if( ret == 1 )
return -1; //创建对象失败
else if( ret == 2 )
return -2; //数据库打开失败
try
{
sql.Format("select count(*) from %s", tablename.c_str() );
/*if( way == 0 ) //查询全部
{
sql.Format("select * from %s", tablename.c_str() );
TRACE("sql = %s\n",sql);
}
else if( way == 1 ) //按字段查询
sql.Format("select %s from %s", field.c_str(), tablename.c_str() );
else if( way == 2 ) //按条件全部查询
{
}
else if( way == 3 ) //按条件和字段联合查询
{
}*/
pset = m_dbptr->Execute((_bstr_t)sql.GetBuffer(sql.GetLength()),&count,adCmdUnknown);
if( pset != NULL && !pset->ADOEOF )
retu
相关问答:
access 中执行sql update语句时有时候成功有时候不成功,但是access中不出错误信息,不知道是什么原因,有哪位大侠知道,请帮忙啊
贴SQL语句,检查表、字段的有效性设置
sql 在查询分析器里面 执行很正常
是 ......
我有一个Units表,结构为:
ID UnistsName
UN1 黑龙江东方学院
UN2   ......
sql语句:
SELECT top 12 Forum.ID,Forum.topic,Reforum.id,Reforum.username,Reforum.posttime,Reforum.postip,Forum.username from Forum INNER JOIN Reforum ON Forum.ID = Reforum.topicid wher ......