ÈçºÎͨ¹ý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Êý¾Ý¿âÀïÃæÐ´¼Ç¼£¬Ã¿Ììд5ÍòÌõ£¬µÚ¶þÌìɾ³ýǰһÌìµÄ5ÍòÌõ
µ«ÊÇaccessÎļþµÄÌå»ý»áÂýÂýÔö¼Ó¡£¡£¡£
ÎÒ²»Ñ¹ËõÊý¾Ý¿âµÄÇé¿öÏ£¬Ê²Ã´Ê±ºòÊý¾Ý¿âµÄÌå»ý²Å²»Ôö¼ÓÄØ£¿
ÎÒɾ³ý¼Ç¼µÄʱºò£¬Êý¾Ý¿âÌå ......
ÎÒÔ±¾ÊÇÓÃACCESSµÄÊý¾Ý¿â£¬ÏÖÔÚ¸ÄÓÃSQLServer2005ÁË£¬ËùÒÔÏë°Ñ֮ǰµÄÊý¾ÝÈ«¶¼µ¼µ½SQLSERVERÀïÀ´¡£
ÏÖÓÐÎÊÌâÈçÏ£º
1:¸ÄÓÃSQLserverºó£¬Êý¾Ý¿âµÄ½á¹¹Óи͝¡£Ô±¾ÔÚaccessÖÐËùÓеĵ¥¾ÝÓÃÒ»¸ö¡°µ¥¾ÝÐÅÏ¢¡±Ö ......
¸øaccessÊý¾Ý¿â¼ÓÃܵIJ½ÖèÈçÏ£º
£¨1£©´ò¿ªaccessÈí¼þ£¬½çÃæÈçͼ1Ëùʾ
......
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 ......
ÎÊÌâÈçÏ£º
ÓòéѯÓï¾ä
select * from tab where fil like 'CK090902'ÄܲéÕÒ³öÒ»Ìõ¼Ç¼²¢ÏÔʾ³öÀ´
¸ÄΪ
select * from tab where fil = 'CK090902'
¾Í²»ÄܲéÕÒµ½£¬Ò²ÏÔʾ²»³öÀ´ ......