ÈçºÎͨ¹ý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
Ïà¹ØÎÊ´ð£º
ÎÒÓÐÒ»¸öUnits±í,½á¹¹Îª:
ID UnistsName
UN1 ºÚÁú½¶«·½Ñ§Ôº
UN2   ......
sqlÓï¾äÊÇÕâÑùдµÃ
string sql = "select * from shophistory where username(stringÀàÐÍ)¡¡like '%"+ name +"%' ";
½á¹ûÔËÐб¨´í£º(²Ù×÷·û¶ªÊ§) ÔÚ²éѯ±í´ïʽ ˵ºó ......
m_pConnect->BeginTrans();
strSql.Format("CREATE TABLE SysUser(lsh AUTOINCREMENT NOT NULL UNIQUE,PRIMARY KEY(lsh),userType BYTE)");
m_pConnect->Execute((_bstr_t)strSql,NULL, adExe ......
SQL code:
select count(1) from HouseList a left join MemberList b on
(a.OperationName=b.UName and a.Eid=1 and a.houselc='2')
ÒÔÉÏÕâÌõÓï¾äÔÚsql2005ÖвéѯµÃµ½760Ìõ¼Ç¼,·ÅÔÚaccessÖвéѯֻÓÐ14Ì ......