ÈçºÎͨ¹ý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Óï¾äÈçÏ£ºselect pid,product_Type.name as tid,name,img_url,context,remark from Product join product_Type on product.type_id = product_Type.type_id order by pid ......
ÔÚaccessÖÐÔõôִÐÐselect TOP (@size) * from table1
Õâ¸öTOPÔõô´ø²ÎÊý²éѯ°¡
ÓÃVBA¶¯Ì¬Éú³ÉSQLÓï¾ä£¬ÔÙÖ´ÐÐ
²»ÄÜÖ±½ÓÓÃSQLÓï¾ä£¬ÓÃ×Ö·û´®ÀÛ¼ÓÉú³ÉSQLÓï¾äµÄ·½·¨À´Ö´ÐÐSQLÓï¾ä
top n Õâ¸öûÓа취ʹÓò ......
ÎÊÌâÈçÏ£º
ÓòéѯÓï¾ä
select * from tab where fil like 'CK090902'ÄܲéÕÒ³öÒ»Ìõ¼Ç¼²¢ÏÔʾ³öÀ´
¸ÄΪ
select * from tab where fil = 'CK090902'
¾Í²»ÄܲéÕÒµ½£¬Ò²ÏÔʾ²»³öÀ´ ......