如何通过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 在查询分析器里面 执行很正常
是 ......
sql语句是这样写得
string sql = "select * from shophistory where username(string类型) like '%"+ name +"%' ";
结果运行报错:(操作符丢失) 在查询表达式 说后 ......
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 ......
//**********************************
//程序功能:创建Access数据库和数据表
//**********************************
unit Unit1;
interface
uses
Windows, Messages, SysUtils, ......
请教
在access中 我有表1
id1 id2 id3 id4
1 2 3 0
2&nb ......