MS SQL Server MFC DAO ÀàºÍ MFC ODBC ÀࣺÎÒʹÓÃÄĸöÀ༯£¿
×÷Õß:microsoft À´Ô´:microsoft
±ÈÒÔÍù¸üÁé»î
MFC Êý¾Ý¿â²ßÂÔ
һϵÁÐÑ¡Ïî
MFC µÄ ODBC Êý¾Ý¿âÀà
Êý¾Ý·ÃÎʶÔÏó
DAO SDK Àà
±È½Ï MFC Êý¾Ý¿âÀà
ÓÅ»¯ÄúµÄ MFC Êý¾Ý¿âÓ¦ÓóÌÐò
½áÂÛ
Jocelyn Garner
±ÈÒÔÍù¸üÁé»î
×Ô MFC Êý¾Ý·ÃÎʶÔÏó (DAO) Êý¾Ý¿âÀàÔÚ 1995 Äê 10 Ô·¢²¼ÒÔÀ´£¬MFC Êý¾Ý¿â¿ª·¢ÈËÔ±¾ÍÒÑ¿ªÊ¼¿¼ÂǸÃʹÓÃÄĸöÀ༯¡£±¾°×ƤÊé²¢²»Á¦Í¼Óó£¹æÊõÓï»Ø´ð´ËÎÊÌâ¡£Ïà·´£¬ÕâÀïҪǿµ÷µÄÊǶԸ÷ÖÖÑ¡Ôñ½øÐмì²é£¬ÒÔ±ãÄú£¨¼´¿ª·¢ÈËÔ±£©¿ÉÒÔÈ·¶¨Ã¿ÖÖÇé¿ö×îÊʺÏʹÓÃÄĸö MFC Êý¾Ý¿âÀ༯¡£
´ó¶àÊý MFC ¿ª·¢ÈËÔ±¶¼ÊìϤ¿ª·ÅʽÊý¾Ý¿âÁ¬½Ó (ODBC) Êý¾Ý¿âÀà - ËüÃÇÔçÔÚÈýÄê°ëÒÔÇ°¾Í³öÏÖÁË¡£ÔÚ MFC 4.2 ÖУ¬¶ÔÕâЩÀàÓÐһЩÖØÒªµÄ¸Ä½ø¡£
ÉíΪ C++ ¿ª·¢ÈËÔ±£¬Äú¿ÉÄܲ»ÊìϤ DAO£¬ÒòΪµ½Ä¿Ç°ÎªÖ¹Ëü»¹Ö»¿ÉÓÃÓÚ Microsoft Access ºÍ Visual Basic® ³ÌÐòÉè¼Æϵͳ¡£Èç¹ûÄúÊìϤ DAO£¬¾Í±ØÐëÁ˽⣺DAO ÔÚ MFC ÖеÄʵÏÖÆÄÓв»Í¬£¬µ«°üÂ޹㷺¡£
Á˽â MFC ODBC ÀàµÄ¿ª·¢ÈËÔ±±ØÐëÖªµÀ£ºËäÈ» MFC DAO Àà±È ODBC À๦ÄÜÐÔ¸üÇ¿£¬µ« DAO À಻ÄÜ´úÌæËüÃÇ¡£
MFC Êý¾Ý¿â²ßÂÔ
¶ÔÓÚÄÇЩ²»ÔõôÊìϤ MFC µÄÈË£¬ÎÒÏëÌáÐÑÒ»¾ä£ºMFC ÓÐÒ»¸öÊÊÓÃÓÚ¸÷ÖÖÊý¾Ý¿âÀàµÄÉè¼ÆÔÔò¡£
MFC ÏñÒ»Õű¡±¡µÄ°ü×°Ö½ÄÇÑù£¬·â×° Windows® ²Ù×÷ϵͳ API£¬ÌṩÄúÏëÒªµÄ C++ ÐÔÄÜ£¬Í¬Ê±ÌṩÄúÐèÒªµÄ³éÏó¸ÅÄî¡£µ±»ù´¡ API ¾ßÓÐʵ¼ÊÒâÒåʱ£¬ÏòÆäÌí¼ÓÖµ¡£¿ÉÊǶàÊýʱºò MFC Á¦Í¼±£³Ö²»ÎªÈË´¥¼°¡£
¾ÍÈç MFC ·â×°¸ü¸´Ô API Ò»Ñù£¬Êý¾Ý¿âÀàÒ²·â×°¸ü¸´Ôӵļ¼Êõ¡£ÒòΪ MFC ¿ÉÒÔÔÚ Intel¡¢Unix ºÍ Alpha Ö®¼ä½øÐÐÒÆÖµ£¬ËùÒÔÊý¾Ý¿âÓ¦ÓóÌÐò½â¾ö·½°¸Ò²ÊÇ¿ÉÒÆÖµµÄ¡£
ÎÒÃÇÓë Microsoft Access¡¢Visual Basic ʹÓÃÏàͬµÄ¼Ç¼¼¯Ä£ÐÍ£¬Òò´Ë£¬ÒѾʹÓÃÄÇЩ²úÆ·µÄ¿ª·¢ÈËÔ±²»±Øѧϰеķ¶Àý¡£ÁíÍ⣬Á½¸öÀ༯µÄÌåϵ½á¹¹»ù±¾Ïàͬ£¬Ê¹ÓÃÆäÖÐÒ»¸öÀ༯µÄ¿ª·¢ÈËÔ±¿ÉÒÔÇáËɵØÇл»µ½ÁíÒ»¸öÀ༯²¢Ê¹ÓÃËü¡£
MFC Êý¾Ý¿âÀà
×Ô´Ó 1.5 °æÖ®ºó£¬MFC ÖоÍÒѾ°üº¬ ODBC Êý¾Ý¿âÀà¡£Visual C++ 2.0 °æÌṩÁ˺¬ÓÐÏàͬÀàµÄ 32 λ°æ±¾¡£ÕâЩÀà»ùÓÚÒ»¸ö¹¤ÒµÈϿɱê×¼£¬²¢Òѵõ½¹ã·ºÓ¦Óã¬ÇÒÒòÆä ODBC ¾ßÓпÉÒÆÖ²ÐÔ¶øÊܵ½ÆäËüÊý¾Ý¿â¿ª·¢Ñ¡Ôñ·½°¸µÄÇàíù¡£ÕâÖÖ¿ÉÒÆÖ²ÐÔÊÇÖ¸Äܹ»½«Ðí¶à ODBC Êý¾ÝÔ´ÓëÓÃÕâЩÀà´´½¨µÄÓ¦ÓóÌÐòÒ»ÆðʹÓ᣽üÀ´µÄÐÔÄܸĽøʹµÃ ODBC Êý¾Ý¿âÀà³ÉΪһ¸öÎüÒýÈ˵ÄÑ¡Ôñ·½°¸¡£
ÔÚ¶àÊýÇé¿öÏ£¬MFC 4.0 ÖÐµÄ DAO Êý¾Ý¿âÀàÔÊÐíÄúÖ±½Ó·ÃÎÊ×ÀÃæÊý¾ÝÔ´¶øÎÞÐëʹÓà ODBC¡£DAO Êý¾Ý¿âÀàËù¾ßÓеÄͬʱ´ò¿ª¶à¸öÊý¾Ý¿âÀàÐ͵ÄÄÜÁ¦¡¢Ê¹ÓöàÊý¾ÝÔ´µÄÄÜÁ¦ÒÔ¼°Êý¾Ý¶¨ÒåÓïÑÔÄÜÁ¦£¬Ê¹Æä³ÉΪÖØÒªµÄ¿ª·¢Ñ¡Ôñ·½°¸¡£
ÏÖÔÚ£¬ÄúÒѾ׼±¸ºÃÌá³öÕâ¸öÎÊÌ⣬×Ô¼ºÓ¦Ê¹ÓÃÄĸöÊý¾Ý¿âÀ༯ºÏ¡£Èç¹ûÄúËùÌṩµÄÓйØ×Ô¼ºÏîÄ¿µÄÐÅÏ¢²»¶à£¬¾ÍºÜÄÑÈ·¶¨Õâ¸öÎÊÌâµÄ´ð°¸¡£µ«ÊÇ£¬µÚÒ»¼þÒª¿¼ÂǵÄÊÂÇéÊÇÄúʹÓÃʲôÊý¾ÝÔ´¡£Èç¹ûÄúͨ³£Ê¹ÓÃ×ÀÃæÊý¾Ý£¬ÎÒÃǹÄÀøÄú¿¼ÂÇ MFC DAO Êý¾Ý¿âÀ࣬ÒòΪÄú½«»á·¢ÏÖËüÃǼ«ÎªÓÐЧÇÒ¹¦ÄÜÇ¿´ó¡£Èç¹ûÄúÖ÷ҪʹÓà ODBC£¨»ùÓÚ·þÎñÆ÷£©µÄÊý¾Ý£¬ÔòʹÓûùÓÚ ODBC µÄÀà»áʹÄúÏîÄ¿µÄ½øÕ¹¸ü¸»³ÉЧ¡£
ÆäËü¿¼ÂÇÊÂÏî°üÀ¨ÍøÂçÖÖÀà¡¢¿ÉÉìËõÐÔÒªÇó£¬ÒÔ¼°ËÙ¶ÈÊÇ·ñÊÇ×îÖØÒªµÄÒòËØ¡£×îºÃÊÇÓÃÄúÈÏΪ¹¤×÷µÃ×îºÃµÄÊý¾Ý¿âÀ༯ÈÃÓ¦ÓóÌÐò±£³ÖÔÐÍ¡£¿ÉÒÔ½øÐÐһЩ»ù×¼²âÊÔ£¬ÒÔÈ·¶¨ÄúµÄ×î¼ÑÐÔÄÜÑ¡Ôñ¡£
ÕæÕýµÄ¾ö¶¨È¨ÔÚÄú¡£
һϵÁÐÑ¡Ïî
Äú¿ÉÓÃÀ´´´½¨Êý¾Ý¿âÓ¦ÓóÌÐòµÄÑ¡ÏºÏºÜ´ó¡£Ëüʵ¼ÊÊÇÍêÕûµÄһϵÁÐÑ¡Ïһ¶ËÊÇ×ÀÃæÊý¾Ý¿âÓ¦ÓóÌÐò£¬ÁíÒ»¶ËÊÇÑϸñµÄ¿Í»§/·þÎñÆ÷Êý¾Ý¿âÓ¦ÓóÌÐò¡£½öÓеÄÁ½ÖÖ¿´ËÆÃ÷ÏÔµÄÑ¡Ôñ¿ÉÄÜÊÇ£ºÔÚ Microsoft Access 97 MDB Êý¾ÝÖÐʹÓà MFC DAO Êý¾Ý¿âÀ࣬¶øÔÚ Microsoft SQL Server ™ 6.5 ÖÐʹÓà MFC ODBC Êý¾Ý¿âÀà¡£ÕâÁ½ÖÖ×éºÏÖ÷ÒªÊÇ»¥ÏàÅäºÏʹÓõģ¬¾ù·Ç³£ÓÐЧ¡£µ«Äú¿ÉÄÜÒѶÔÕâЩѡÔñÓÐËùÁ˽⣬ÆäËüÇé¿öÓÖ¸ÃÈçºÎÄØ£¿
¼òÒªµØ˵£¬ÒÔÏÂÊÇÄúÀµÒÔ¾ö²ßµÄ¹ý³Ì£º
È·¶¨Êý¾ÝÔ´ÐèÇó
ÄúÐèÒªµÄÊý¾Ý¿âÓжà´ó£¿ Ò»´Î»áÓжàÈËÐèÒª·ÃÎÊÊý¾ÝÂ𣿠ÓÐʱ£¬ÆäÓàµÄ´ó¶àÊý²½Öè¾ùÈ¡¾öÓÚÄúÑ¡ÔñµÄÊý¾ÝÔ´¡£
È·¶¨½Ó¿ÚÐèÇó
Èç¹ûÄúÐèÒªµÄ½Ó¿ÚÓдóÁ¿µÄÓû§ÊäÈ루ÈçÓû§¿ÉÒÔÉè¼Æ×Ô¼ºµÄ²éѯ£©£¬ÄÇôÔÚµ÷ÕûºÍ·Ö·¢Êý¾Ý¿â£¨Ò»¸ö»ò¶à¸ö£©Ê±¾Í±ØÐëÒªÉ÷ÖØ¡£ÀýÈ磬Èç¹ûÐèÒªÓñ仯²»´óµÄÊý¾ÝÌî³äÁбí¿ò£¬²¢ÇÒÒÑÑ¡Ôñ»ùÓÚ·þÎñÆ÷µÄÊý¾ÝÔ´£¬Ôò½«Í¨³£²»±ä»¯µÄÊý¾Ý´æ´¢ÔÚ±¾µØ¶ø·Ç·þÎñÆ÷ÉÏ£¬ÊÇÒ»ÖÖÓÐÒâÒåµÄ×ö·¨¡£
È·¶¨Á¬½ÓÐÔÐèÇó
ĿǰʹÓõÄÍøÂçÐÒéÓкܶàÖÖ£¬Ã¿ÖÖÐÒ鶼¶Ôͨ¹ýÍøÂç´«Ë͵ÄÊý¾Ý¸÷Óв»Í¬Ó°Ïì¡£¹ØÓÚÍøÂçµÄÌÖÂÛ²»ÊDZ¾°×ƤÊé·ÝÄÚ֮ʣ¬µ«ÄúÐèÒªÁ˽âÈçºÎÓÅ»¯×Ô¼ºµÄÊý¾Ý¿âÓ¦ÓóÌÐò£¬ÒÔ±ÜÃâÓöµ½ÍøÂçµÄÊý¾ÝÏÝÚå¡£
Ñ¡ÔñÊʵ±µÄ¹¤¾ß£¨Ò»¸ö»ò¶à¸ö£©
Microsoft ΪÊý¾Ý¿â¿ª·¢ÈËÔ±ÌṩÁ˶àÖÖ¿ÉÑ¡ÔñµÄ¹¤¾ß£¨Microsoft Access¡¢Visual Basic¡¢Visual Basic Enterprise¡¢Visual C++/MFC ÒÔ¼° SQL Server£©£¬ÔÚijЩÇé¿öÏÂËüÃǵŦÄÜÂÔÓÐÖصþ¡£±¾°×ƤÊéÖ¼ÔÚÌÖÂÛ Visual C++/MFC Ñ¡Ïî¡£µ«Èç¹ûÄú»¹Î´¿¼ÂÇÆäËüÑ¡ÏӦ¸ÃÒ²¶ÔËüÃÇÉÔ¼ÓÁ˽⡣
ÔÚʵʩǰ±£³ÖÔÐÍ
ÔÚ±¾°×ƤÊéÖÐÄú½«Êý´Î¿´µ½´Ë³ÂÊö£¬ÒòΪËüºÜÖØÒª¡£Äú¿ÉÄÜÒÑ×öÁ˺ܺõÄÑ¡Ôñ£¬µ«³ý·ÇÄúµÄ½â¾ö·½°¸ÕæµÄÆðÁË×÷Ó㬷ñÔò¹¤×÷¾Í²»ËãÍê³É£¡
´ËÍ⣬¹ØÓÚ±¾°×ƤÊ飬ÎÒÃǼÙÉèÄúÏëÁ˽âµÄÊÇ MFC µÄÊý¾Ý¿âÀà¡£ÎÒÃDz»·Á¾¡¿ÉÄܶàµØ¼ì²éһЩѡÔñ·½°¸£¬ÒÔ±ãÄúÈÏ¿ÉÄúÏëΪ×Ô¼ºµÄµÚÒ»¸öÔÐͲÉÓõÄÖ¸µ¼¡£
MFC ODBC Êý¾Ý¿âÀàʹÓà Microsoft Access ºÍ Visual Basic ÖеļǼ¼¯Ä£ÐÍ¡£Äú¿ÉÒÔÓÃÄÚÖÃÓÚÀàÖеijÉÔ±º¯Êý¶Ô¼Ç¼½øÐÐɸѡ¡¢·ÖÀà¡¢¹ö¶¯ÒÔ¼°ÆäËü´¦Àí¡£»ù´¡ ODBC Çý¶¯³ÌÐò»áÓ°ÏìÌØÊâÓ¦ÓóÌÐòµÄ¹¦ÄÜ¡£Òò´Ë£¬ÈôҪʹ¿ÉÒÆÖ²ÐÔ¸üÇ¿£¬ÄúµÄÓ¦ÓóÌÐò¾Í±ØÐë¸ü¾ßÓÐͨÓÃÐÔ£¬»òÕß±ØÐëÒÀÀµÓÚ¸üµÍ¼¶±ðµÄ ODBC ¹¦ÄÜ¡£ÈçÓбØÒª£¬¿ÉÒÔÖ±½Óµ÷Óà ODBC£¬ÒÔÍê³ÉÌØÊâÈÎÎñ¡£ÏÖÔÚ£¬ÈÃÎÒÃǼì²é¸Ã¼¯ºÏÖеĵ¥¸öÀà¡£
MFC µÄ ODBC Êý¾Ý¿âÀà
¾ÍÏóʹÓà MFC ÄÇÑù£¬±ØҪʱ¿ÉÒÔµ÷Óûù´¡ API£¨ÔÚ´ËÇé¿öÏÂΪ ODBC£©¡£
Ò»¸ö CDatabase ¶ÔÏó´ú±íÒ»¸öµ½Êý¾ÝÔ´µÄÁ¬½Ó£¬Í¨¹ý´ËÁ¬½ÓÄú¿ÉÒÔÔÚÊý¾ÝÔ´ÉϽøÐвÙ×÷¡£Êý¾ÝÔ´ÊÇÖ¸ÒÔijЩÊý¾Ý¿â¹ÜÀíϵͳ (DBMS) ×÷ΪËÞÖ÷µÄÖ¸¶¨Êý¾ÝʵÀý¡£¾ßÌåʾÀý°üÀ¨ Microsoft SQL Server¡¢Microsoft Access¡¢Borland dBASE ºÍ xBASE¡£Äú¿ÉÒÔÔÚ×Ô¼ºµÄÓ¦ÓóÌÐòÖÐͬʱÈÃÒ»¸ö»ò¶à¸ö CDatabase ¶ÔÏó´¦Óڻ״̬£¬²¢ÇÒ¿ÉÒÔ±£³Öµ½Ò»¸öÊý¾Ý¿â¶ÔÏóµÄ¶à¸öÁ¬½Ó¡£
Ò»¸ö CRecordset ¶ÔÏó´ú±í´ÓÊý¾ÝÔ´ÖÐÑ¡ÔñµÄÒ»¸ö¼Ç¼¼¯ºÏ¡£³ÆΪ¡°¼Ç¼¼¯¡±µÄ CRecordset ¶ÔÏóÓÐÈýÖÖ¿ÉÓõÄÐÎʽ£º¶¯Ì¬¼¯¡¢¿ìÕÕ¡¢¶¯Ì¬¼Ç¼¼¯¡£¶¯Ì¬¼¯ÊÇÓëÆäËûÓû§µÄ¸üб£³Öͬ²½µÄ¼Ç¼¼¯¡£¿ìÕÕÊǾ²Ì¬¼Ç¼¼¯£¬Ëü·´Ó³µÄÊÇ×¥ÅÄ¿ìÕÕʱÊý¾Ý¿âµÄ״̬¡£¶¯Ì¬¼Ç¼¼¯ÀàËÆÓÚ¶¯Ì¬¼¯£¬µ«Í¨³£Ö»ÓÃÓÚ Microsoft SQL Server¡£Ã¿ÖÖÐÎʽ¶¼´ú±íÔÚ´ò¿ª¼Ç¼¼¯Ê±È·¶¨µÄ¼Ç¼¼¯ºÏ£¬µ«µ±ÄúÔÚ¶¯Ì¬¼¯ÄÚ»ò¶¯Ì¬¼Ç¼¼¯ÄÚ¹ö¶¯µ½Ò»Ìõ¼Ç¼ʱ£¬Ëü·´Ó³ºóÀ´ÓÉÆäËûÓû§»òÄúÓ¦ÓóÌÐòÖеÄÆäËü¼Ç¼¼¯¶Ô¼Ç¼Ëù×öµÄ¸ü¸Ä¡£
MFC 4.2 ÒÔÊéÇ©µÄÐÎʽÏò CRecordset ÀàÖÐÌí¼Óеĵ¼º½¹¦ÄÜ£¬²¢Ìí¼Ó±êʶ¼°µ¼º½µ½¼Ç¼µÄ AbsolutePosition µÄÄÜÁ¦¡£ÊéÇ©ÊÇΨһµÄ±êʶ·û£¬Í¨¹ýµ÷Óøñêʶ·û¿É·µ»ØÖ¸¶¨µÄ¼Ç¼¡£
Àà CRecordView ÊÇÒ»ÖÖ MFC ¹¹Ôì - Ò»ÖÖÏÔʾÊý¾ÝµÄÐÎʽ¡£ÒòΪ CRecordView ÊÇ»ùÓÚ CFormView µÄ£¬ËùÒÔËü¾ßÓиûù´¡ÀàµÄËùÓÐÒÅ´«¹¦ÄÜ¡£´Ó±¾ÖÊÉÏ˵£¬´°ÌåÊÓͼÔÚ´°¿ÚµÄ¿Í»§¶ËÇøÓòÉìÕ¹¶Ô»°¿òÄ£°å¡£ÕâʹµÃÌí¼Ó¿Ø¼þÓëÏÔʾ×Ö¶ÎÊý¾Ý¼«ÎªÈÝÒס£
µ±Ê¹Óà AppWizard ºÍ ClassWizard ´´½¨»ùÓÚ ODBC µÄÊý¾Ý¿âÓ¦ÓóÌÐòʱ£¬¼Ç¼¼¯µÄÁлá×Ô¶¯°ó¶¨µ½£¨¾²Ì¬µØ£©³ÉÔ±±äÁ¿£¬ÕâЩ±äÁ¿¿ÉÒÔËæºóÌí¼Óµ½¶Ô»°¿òÄ£°åÖС£
Ò»¸ö CDBException ¶ÔÏó´ú±íÒ»ÖÖÓÉÊý¾Ý¿âÀàÒýÆðµÄÒì³£´íÎóÌõ¼þ¡£¸ÃÀàÖк¬ÓÐÁ½¸ö¹«¹²Êý¾Ý³ÉÔ±£¬¿ÉʹÓÃÕâÁ½¸ö³ÉԱȷ¶¨µ¼ÖÂÒì³£´íÎóµÄÔÒò£¬»òÏÔʾ¶ÔÒì³£´íÎó½øÐÐ˵Ã÷µÄÎı¾ÏûÏ¢¡£CDBException ¶ÔÏóÓÉÊý¾Ý¿âÀàµÄ³ÉÔ±º¯Êý¹¹ÔìÓëÅ׳ö¡£
CFieldExchange ÀàÖ§³ÖÓÉÊý¾Ý¿âÀàʹÓõļǼ×ֶν»»» (RFX) Àý³Ì¡£Èç¹ûÄúÕýÔÚ±àд×Ô¶¨ÒåÊý¾ÝÀàÐ͵ÄÊý¾Ý½»»»Àý³Ì£¬ÔòʹÓøÃÀࣻ·ñÔò£¬Äú²»»áÖ±½ÓʹÓøÃÀà¡£RFX ÔÚÄú¼Ç¼¼¯¶ÔÏóµÄ×Ö¶ÎÊý¾Ý³ÉÔ±ºÍÊý¾ÝÔ´Éϵ±Ç°¼Ç¼µÄÏàÓ¦×Ö¶ÎÖ®¼ä½»»»Êý¾Ý¡£RFX ¹ÜÀíÁ½¸ö·½ÏòÖеĽ»»»£¬¼´À´×ÔÊý¾ÝÔ´µÄ½»»»Óëµ½Êý¾ÝÔ´µÄ½»»»¡£
Êý¾Ý·ÃÎʶÔÏó
ÔÚ DAO µÄ±¾»ú¸ñʽÖУ¬°üº¬ 21 ¸ö¶ÔÏóºÍ 20 ¸ö¼¯ºÏ¡£¶øÇÒ£¬DAO ²»½öÌṩµ¥¸öµÄ¶ÔÏó£¬Èç±íºÍ×ֶΣ¬»¹Ìṩ¶ÔÏóËùÊôµÄ¼¯ºÏ¡£¶ÔÏóµÄÕâÖÖÇåÎúµÄ²ã´Î½á¹¹Ê¹µÃÄܹ»ÇáËɵؽ«ÃæÏò¶ÔÏóµÄÔÀíÓ¦ÓÃÓÚÊý¾Ý¿â¿ª·¢¡£
DAO µÄ´æÔÚÒÑÓÐÒ»¶Îʱ¼ä¡£DAO 1.0 °æ³öÏÖÔÚ Microsoft Access 1.0 °æÖУ¬Ëü½öÌṩµ½±íÓë²éѯ½á¹¹µÄ½Ó¿Ú£¬ÒÔ¼°´ú±í¾ßÓÐÊýÁ¿ÓÐÏÞµÄÊôÐÔµÄ±í¡¢¶¯Ì¬¼¯¡¢¿ìÕյĶÔÏó¡£Visual Basic 3.0 °æÖÐµÄ Data Access Objects 1.0 Ìí¼ÓÁË TableDef¡¢QueryDef ºÍ Field ¶ÔÏó£¬ÒÔÌṩ¿É±à³ÌµÄ½á¹¹¡£
Microsoft Access 2.0 °æÖÐµÄ DAO 2.0 °æÓÐ OLE ×Ô¶¯»¯µÄ³ûÐΣ¬ÒÔ¼°¶Ô¼¸ºõËùÓÐ Microsoft Jet ¹¦ÄܵÄÈ«²¿±à³Ì·ÃÎÊȨÏÞ¡£ËüÓµÓоßÓпɿ¿µÄ¶ÔÏóÓëÊôÐÔ¼¯ºÏµÄÈ«²¿¶ÔÏóÄ£ÐÍ¡£
DAO 2.5 °æÖк¬ÓÐ ODBC ×ÀÃæÊý¾Ý¿âÇý¶¯³ÌÐò (ODBC Desktop Database Driver)£¬ÕâЩÇý¶¯³ÌÐòÊÇΪ 16 λƽ̨ÄÜÓë ODBC Desktop Database Drivers 2.0 °æÒ»ÆðʹÓöø´´½¨µÄ¡£¸Ã 16 λ°æ±¾ÊÇΪÓÃÓÚ Visual Basic 4.0 °æµÄ 16 λ°æ±¾¶ø°²×°µÄ¡£
DAO 3.0 °æËæ´øÔÚ Microsoft Access for Windows 95¡¢Visual Basic 4.0 °æ£¨32 룩¡¢Microsoft Excel 7.0 °æ ºÍ Visual C ++ 4.0 °æÖС£DAO µÃµ½ÁËÔöÇ¿£¬ÒÔÖ§³ÖÈκμæÈÝÖ÷»úµÄµ¥»ú½Ó¿Ú¡£
DAO 3.5 °æËæ´øÔÚ Microsoft Access for Windows 97 ÖУ¬²¢ÇÒº¬ÓÐÐ嵀 ODBCDirect COM ¶ÔÏó¡£MFC DAO Êý¾Ý¿âÀ಻°üÀ¨ÕâЩ¶ÔÏóµÄÀà¡£
×îΪÖØÒªµÄÊÇ£¬DAO ½Ó¿ÚÊÇ»ùÓÚ OLE COM µÄ£¬ËüºÜºÃµØ°²Öà DAO ÒÔÊÊÓ¦²»¶Ï·¢Õ¹µÄ¼¼ÊõºÍ²Ù×÷ϵͳ¡£
´Ë´¦ÊÇ DAO ²ã´Î½á¹¹Í¼±í¡£ÔÚ¶¥¶Ë£¬½«¿´µ½ DBEngine ¶ÔÏ󣬸öÔÏóÖк¬ÓÐËùÓÐÆäËü¶ÔÏó¡£ÕâÊÇΨһûÓм¯ºÏµÄ¶ÔÏó£¬ÒòΪÄúÖ»ÄÜÓÐÒ»¸öÒýÇæ¡£µ«¿ÉÒÔÓжà¸ö¹¤×÷Çø (Workspace)¡¢Êý¾Ý¿â (Database) µÈµÈ£¬ÕâÕýÊÇÓàϵĶÔÏó¶¼ÓÐ×Ô¼ºËùÊô¼¯ºÏµÄÔÒò¡£
ÔÚ¹¤×÷ÇøÖУ¬¿ÉÒÔÓжà¸öÊý¾Ý¿â£¬Ò»¸ö»ù±¾±í (.MDB) »òÒ»¸ö¸½¼Ó/Á´½ÓµÄ±í¡£ÔÚÿ¸öÊý¾Ý¿âÖн«ÓÐÒ»¸ö»ò¶à¸ö±í¡¢²éѯ¡¢¼Ç¼¼¯£¬¶øÆäÖеÄÿ¸ö±í¡¢²éѯ¡¢¼Ç¼¼¯²»½ö°üº¬×ֶκͣ¨»ò£©Ë÷Òý£¬»¹ÓÐÆäËüÀàÐ͵ĶÔÏó¡£
ÁíÍ⣬Ó빤×÷ÇøÁ¬½ÓµÄÊÇÓû§¶ÔÏóºÍ×é¶ÔÏó£¬ËüÃÇÐγÉÁË DAO µÄ°²È«Ä£ÐÍ¡£
¶ÀÁ¢µ«ÓëÒýÇæ¶ÔÏóÁ¬½ÓµÄÊÇ Errors ¶ÔÏó¡£
Errors ¼¯ºÏÖжÔÏóµÄ¸½¼Ó·½Ê½²»Í¬ÓÚÆäËü DAO ¼¯ºÏ¡£×îÏêϸµÄ´íÎó·ÅÔÚ¼¯ºÏµÄĩ⣬×î³£¹æµÄ´íÎó·ÅÔÚ¿ªÍ·¡£
MFC ºÍ DAO
ÏÖÔÚҪ̸µÄÊÇ MFC ÈçºÎʵÏÖ DAO¡£ÒòΪÎÒÃDz»ÊÇ·Ö±ð°üװÿ¸ö DAO ¶ÔÏó£¬ËùÒÔʵ¼ÊÉÏ MFC »áƽչ DAO µÄ²ã´Î½á¹¹¡£ÎÒÃÇΪÄúÌṩ 8 ¸ö¶ÔÏó¶ø²»ÊÇ 21 ¸ö¶ÔÏó¡£
ÎÒÃÇ·â×°ËùÓÐµÄ DAO ¹¦ÄÜ£¬³ý Security ¶ÔÏóÍâ - Users ¶ÔÏó¡¢Groups ¶ÔÏóÒÔ¼°Ð嵀 ODBCDirect ¶ÔÏó¡£ÕâÊÇÎÒÃÇÓÐÒâ¶øΪ¡£ÀýÈ磬ÎÒÃǾõµÃÔڲ鿴°²È«ÐÔ¶ÔÏóʱ£¬Î§ÈÆËüÃÇ´´½¨Àཫ²»»á¸ø DAO µÄʹÓÃÌí¼ÓÈκÎÖµ£¬Òò´Ë»¹ÊÇÈÃÄúÖ±½Óµ÷Óà DAO£¬À´´¦ÀíÄÇЩ¶ÔÏó¡£ÕâÒ²ÊÇÓë MFC ÔÔòÒ»ÖµģºÓ¦¸ÃÔÚ¶ÔÌí¼ÓÖµµÄÁ¢³¡¶øÑÔÓÐÒâÒåµÄµØ·½´´½¨Àà¡£µ«ÎÒÃÇÈÔ»áÔÚ MFC Technical Note 54 ÖÐÌṩ¹ØÓÚÈçºÎʵÏÖ°²È«ÐÔÄ£Ð͵ÄÖ¸µ¼¡£
ÁíÍ⣬ÎÒÃÇ»¹¹ÜÀí DAO Òª½«¶ÔÏó×·¼Óµ½¼¯ºÏµÄÒªÇó¡£ÔÚ DAO ÖУ¬Äú´´½¨¶ÔÏó£¬È»ºó½«Ëü×·¼Óµ½¼¯ºÏÖС£³ýÒ»ÖÖÀýÍâÇé¿öÍ⣬ÕâÖÖÌí¼ÓÊÇ×Ô¶¯Íê³ÉµÄ¡£¶ÔÓÚÕâÖÖÀýÍâÇé¿ö£¬¿É×÷Ϊһ¸öµ¥¶ÀµÄ²½ÖèÀ´ÉèÖÿª·¢ÈËÔ±ÄÜ·ñ×·¼Ó¶ÔÏó£¬ÕâÊǺÜÓõġ£
ËäÈ»¿ÉÄÜÓà ODBC Êý¾Ý¿âÀà½øÐж¯Ì¬°ó¶¨£¬µ«ÊµÏÖÕâһĿµÄµÄ¹¦Äܲ¢·Ç MFC ÀàµÄÄÚÖù¦ÄÜ¡£Ëü±»ÖÃÈë DAO Êý¾Ý¿âÀ࣬Äú¿ÉÒÔÏ൱ÇáËɵؽøÐж¯Ì¬°ó¶¨¡£ÏÖÔÚÎÒÃǵĵڶþ¸öÑÝʾ½«¸ü¶àµØ̸¼°ÕâÒ»µã¡£
DAO ÌṩÀ´×Ô SQL µÄÊý¾Ý¶¨ÒåÓïÑÔ (DDL)£¬ÒÔ±ãÄú´´½¨Êý¾Ý¿â¡¢±í¡¢¼Ç¼¼¯µÈ¡£ÔÚ ODBC ÖÐûÓÐ DDL¡£
×îºó£¬µ±ÄúÐèҪʱ£¬×ÜÊÇ¿ÉÒÔ¶Ô»ù´¡ DAO OLE ¶ÔÏó½øÐÐÖ±½Óµ÷Óá£
MFC DAO Êý¾Ý¿âÀàµÄ²ã´Î½á¹¹
Îå¸öÓÉ CObject ÅÉÉúµÄ MFC DAO ÀࣨCDaoWorkspace¡¢CDaoDatabase¡¢CDaoTableDef¡¢CDaoQueryDef ºÍ CDaoRecordset£©¾ßÓиûù´¡ÀàµÄËùÓй¦ÄÜ¡£
CDaoException ÓÉ CException ÅÉÉúµÃµ½£¬¾ß±¸¸ÃÀàµÄÓŵ㣬°üÀ¨ÏÔʾÀ´×Ô»ù´¡ DAO Errors ¶ÔÏóµÄ´íÎóÏûÏ¢µÄÄÜÁ¦¡£
ÈçÇ°ÃæÌáµ½µÄÄÇÑù£¬CDaoRecordView ÓÉ CFormView ÅÉÉúµÃµ½£¬¶ø CFormView ÓÖÓÉ CScrollView ÅÉÉúµÃµ½£¬ÒÀ´ÎÀàÍÆ¡£¿ÉÒÔ¿´µ½ CDaoRecordView ÀàÔÚ¿ìËÙ¶øÇáËɵØʵÏÖ»ùÓÚ´°ÌåµÄÊý¾ÝÏÔʾ·½ÃæËù¾ßÓеÄÈ«²¿Óŵ㡣´ËÍ⣬»¹ÓжÔÓÚ CDaoRecordView µÄÏòµ¼Ö§³Ö¡£¸ÃÀàÖеŦÄÜʵÖÊÉÏÊÇÓë CRecordView ÀàÒ»ÑùµÄ¡£
CDaoFieldExchange ÀàÖ§³ÖÓÉ DAO Êý¾Ý¿âÀàʹÓÃµÄ DAO ¼Ç¼×ֶν»»» (DFX) Àý³Ì¡£Èç¹ûÒª´´½¨×Ô¶¨ÒåµÄ DFX Àý³Ì£¬Ö»ÒªÖ±½Óµ÷ÓøöÔÏó¼´¿É¡£
MFC DAO Êý¾Ý¿âÀà
CDaoWorkspace ·â×° DBEngine ¶ÔÏóºÍ Workspace ¶ÔÏó¡£MFC DAO ÀàÌṩ¹¤×÷ÇøµÄÊÂʵ·Ç³£ÖØÒª¡£ODBC Êý¾Ý¿âÀ಻ͬʱ֧³Ö¶à¸öÊý¾Ý¿âÁ¬½Ó¡£
ÊÂÎñ´¦ÀíÊÇÔÚ DAO Êý¾Ý¿âÀàÖÐµÄ Workspace£¨¹¤×÷Çø£©¼¶±ðÍê³ÉµÄ£¬¶ø²»ÊÇÔÚ ODBC ÀàÖÐµÄ Recordse£¨¼Ç¼¼¯£©¼¶±ðÍê³ÉµÄ¡£Ò»¸öÊÂÎñ¿ÉÄÜ»áÓ°ÏìËùÓдò¿ªµÄÊý¾Ý¿âºÍ¼Ç¼¼¯£¬»òÕßÄú¿ÉÒÔ¸ôÀëÊÂÎñ£¬Ê¹ÆäÖ»»áÓ°ÏìÖ¸¶¨µÄÊý¾Ý¿â£¬µÈµÈ¡£
¶àÊýʱºò£¬Äú²»±Øµ£ÐŤ×÷Çø¶ÔÏóµÄ´´½¨¡£Èç¹ûÄúδ´´½¨£¬MFC ¾Í½«ÎªÄú´ò¿ªÒ»¸ö¹¤×÷Çø¶ÔÏó¡£Èç¹ûÄúÐèÒªµÄ»°£¬DAO Êý¾Ý¿âÀà¿ÉÖ§³Ö¶à¸ö¹¤×÷Çø¡£
×îºó£¬Äú²»±Øµ£ÐŤ×÷Çø¶ÔÏ󳬳ö·¶Î§»òÊÇÔÚÊý¾Ý¿â»á»°Íê³ÉÇ°¹Ø±Õ¡£¿ÉÒÔʹÓù¤×÷ÇøÖ¸Õë·ÃÎʹ¤×÷Çø¼¯ºÏ£¬·ÃÎÊÊý¾Ý¿â¼¯ºÏ£¬ÒÔ¼°·ÃÎÊÊý¾Ý¿âÒýÇæµÄÊôÐԵȡ£
CDaoDatabase
CDaoDatabase ÔÚÌåϵ½á¹¹ÉÏÀàËÆÓÚ»ùÓÚ ODBC µÄ CDatabase Àà¡£CDaoDatabase Ò²·â×°Êý¾Ý¿âÁ¬½Ó¡£ÒòΪÄú²»±Ø×ÜÊÇʹÓà ODBC£¬ËùÒÔ¶ÔÓÚ´ó¶àÊý×ÀÃæÊý¾ÝÔ´£¬Êý¾ÝÔ´µÄλÖþͱí´ïΪ·¾¶¡£CDaoDatabase ¿ÉÒÔ´æ´¢ tabledef ºÍ querydef ¶ÔÏó£¬ÎªÄúµÄ¿ª·¢ÌṩÁ˼«´ó·½±ã¡£CDaoDatabase ¿ÉʹÓñ¾µØ¼°Ô¶³ÌÊý¾ÝÔ´¡£ÔÚ±¾°×ƤÊéµÄÉԺ󲿷֣¬ÓÐÒ»¸ö¿É¹©ÄúʹÓõÄÊý¾ÝÔ´µÄÁÐ±í¡£
¸ÃÊý¾Ý¿â¶ÔÏóÔڻỰÆÚ¼äÒ²Ò»Ö±¼ÌÐø´æÔÚ¡£±ØҪʱ¿ÉÒÔÃ÷È·µØ¹Ø±ÕÊý¾Ý¿âÁ¬½Ó¡£½ö¾Í±È½Ï¶øÑÔ£¬CDatabase ÀàÓÐ 21 ¸ö³ÉÔ±º¯Êý£¬¶ø CDaoDatabase ÓÐ 26 ¸ö³ÉÔ±º¯Êý¡£ÕâЩ³ÉÔ±º¯ÊýÖб˴ËÏàÓ¦µÄ¶¼·Ç³£ÏàËÆ£¬ÔÚ CDaoDatabase Öл¹Óм¸¸öûÓжÔÓ¦³ÉÔ±º¯Êý¡£
ÔÚ ODBC Êý¾Ý¿âÀàÖÐûÓÐÓë CDaoTableDef ÏàÓ¦µÄÀà¡£TableDef ¶ÔÏóÈÃÄú¼ì²éÊý¾Ý¿âµÄ¼Ü¹¹£¨½á¹¹£©£¬²»ÂÛ±íÊDZ¾»ú Microsoft Access ±í£¨»ù±¾±í£©»¹ÊÇÁ´½ÓµÄ±í¡£Èç¹ûÓà DAO Ö±½Ó´ò¿ªÍⲿÊý¾ÝÔ´£¬¾Í¿ÉÏòÆäÖÐÌí¼Ó×ֶκÍË÷Òý¡£Èç¹ûÄúÁ´½ÓÁË±í£¬¾Í¿ÉÒÔ¼ì²é½á¹¹£¬µ«²»Äܸü¸ÄËü¡£¿ÉÒÔ½«±í×÷Ϊ¼Ç¼¼¯µÄ»ù´¡¡£ÕâÑù×ö»áʹÄú»ñµÃ¼¸¸öºÃ´¦£¬°üÀ¨Ê¹ÓÃÃûΪ Seek µÄ¿ìËÙËÑË÷³ÉÔ±º¯Êý¡£
ʹÓà CDaoTableDef ¿ÉÒÔÈ·¶¨ÊÇ·ñ¿Éͨ¹ýµ÷Óà CDaoTableDef::CanUpdate ±à¼±íÖеÄÊý¾Ý¡£MFC ¸ºÔðΪÄú¹ÜÀí DAO Field ºÍ Index ¼¯ºÏ¡£Ê¹Óà CDaoTableDef ʱ£¬Äú¿ÉÒÔÑ¡ÔñÊÇ·ñÏò TableDefs ¼¯ºÏÖÐ×·¼Ó±í£»¶øʹÓÃËùÓÐÆäËü¶ÔÏóʱ£¬»á×Ô¶¯½øÐÐ×·¼Ó¡£
ÄúÓÃÀ´¼ìË÷¼Ç¼µÄ SQL ´æ´¢ÔÚ CDaoQueryDef ¶ÔÏóÖС£Äú¿ÉÓøöÔÏó´æ´¢ÄúÌá³öµÄÓйØÊý¾ÝµÄ¡°ÎÊÌ⡱£¬Èç¡°How many customers did X dollars of business last month?¡±¡£¿ÉÒÔ¼ìË÷»òÖØÐÂʹÓô洢µÄ²éѯ£¬¿É°´ÏÂÁÐÈýÖÖ·½·¨Ö®Ò»Ê¹ÓÃËüÃÇ£º
ͨ¹ý½«Ö¸Õë´«µÝµ½ CDaoQueryDef ¶ÔÏó¶ø´´½¨¼Ç¼¼¯¡£
Ö±½ÓÖ´ÐвÙ×÷²éѯ£¬¼´Òƶ¯»ò¸ü¸ÄÊý¾ÝµÄ²éѯ¡£²Ù×÷²éѯ°üÀ¨×·¼Ó¡¢É¾³ý¡¢Éú³É±íÒÔ¼°¸üвéѯ¡£É¾³ý²éѯºÍ¸üвéѯ»á¸ü¸ÄÏÖÓÐÊý¾Ý£»¸½¼Ó²éѯºÍÉú³É±í²éѯ»áÒƶ¯ÏÖÓÐÊý¾Ý¡£
Ö´ÐÐ SQLPASSTHROUGH ²éѯ£ºSQL Ö±½Ó´«µÝ²éѯÊÇÖ±½Ó·¢Ë͵½Êý¾Ý¿â·þÎñÆ÷¶ø²»»á±» Microsoft Jet Êý¾Ý¿âÒýÇæÖÐ¶ÏµÄ SQL Óï¾ä¡£SQL Ö±½Ó´«µÝ²éѯΪÄúµÄÓ¦ÓóÌÐòÌṩֱ½ÓʹÓÃÊý¾Ý¿â·þÎñÆ÷µÄ¹¦ÄܵÄÄÜÁ¦¡£
ÁíÍ⣬CDaoRecordset »¹ºÜÀàËÆÓÚ»ùÓÚ ODBC µÄ CRecordset Àà¡£¼Ç¼¼¯²»½ö¿ÉÒÔ»ùÓÚ±í£¬Ò²¿ÉÒÔ»ùÓÚ¶¯Ì¬¼¯ºÍ¿ìÕÕ¡£Çë¼Çס£¬¼Ç¼¼¯´ú±íÄúÒѼìË÷µ½µÄ¼Ç¼ºÍ´©¹ýÊý¾ÝµÄ·½·¨¡£Òƶ¯²¢¹ö¶¯Êý¾ÝµÄ·½·¨°üÀ¨ Seek£¨Ö»ÓÃÓÚ±íÀàÐ͵ļǼ¼¯£©¡¢Find ºÍ Move ²Ù×÷£¬ÒÔ¼° AbsolutePosition ºÍ£¨Èç¹ûÄúµÄÊý¾ÝÔ´Ö§³ÖµÄ»°£©ÊéÇ©¡£ÊéÇ©ÊÇΨһµÄ±êʶ·û£¬¿Éͨ¹ýµ÷Óøñêʶ·ûÀ´·µ»ØÖ¸¶¨µÄ¼Ç¼¡£
MFC DAO Êý¾Ý¿âÀàÖеĴ󲿷ֹ¦ÄÜÊÇ´æÔÚÓÚ CDaoRecordset Öеġ£CRecordset Ö»ÓÐ 44 ¸ö³ÉÔ±º¯Êý£¬ÓëÖ®Ïà±È CDaoRecordset ÓÐ 91 ¸ö³ÉÔ±º¯Êý¡£ÕâÖÖ¶îÍâµÄ¹¦ÄܱíÏÖΪ×Ö¶ÎÖµµÄµ¼º½¡¢¸ßËÙ»º´æ¡¢ÉèÖúͼìË÷ÖУ¬ÒÔ¼°¼Ç¼¼¯ÊôÐÔµÄÉèÖúͼìË÷¡£
CDaoRecordView ºÍ CRecordView ÀàÓм¸ºõÏàͬµÄ¹¦ÄÜ¡£ÁíÍ⣬ËüÃǶ¼»¹¾ßÓÐÒò»ùÓÚ CFormView ¶ø»ñµÃµÄÓŵ㡣Çë¼Çס£¬´°ÌåÊÓͼ¾ÍºÃÏóÔÚ´°¿ÚµÄ¿Í»§¶ËÇøÓòÉìÕ¹µÄ¶Ô»°¿òÄ£°åÒ»Ñù£¬ÓÐÁËËü£¬Ìí¼Ó¿Ø¼þÓëÏÔʾ×Ö¶ÎÊý¾Ý¾ÍºÜÈÝÒס£AppWizard ºÍ ClassWizard Ö§³Ö»ùÓÚ´°ÌåµÄÊý¾ÝÏÔʾ¡£Èç¹ûʹÓà AppWizard ´´½¨³õʼӦÓóÌÐò£¬ÄúÊý¾Ý¿âÖеÄÁоͻá×Ô¶¯°ó¶¨µ½³ÉÔ±±äÁ¿¡£
¶ÔÓÚ DAO Êý¾Ý¿âÀ࣬Òì³£´íÎó´¦ÀíÂÔÓв»Í¬¡£Àà CDaoException ½«·µ»Ø»ù´¡ DAO OLE ¶ÔÏóµÄ´íÎóÏûÏ¢¡£¶àÊýʱºò£¬Äú¿ÉÒÔ¼ìË÷µÄ´íÎóÐÅÏ¢Òª±Èͨ³£²ÉÓûùÓÚ ODBC µÄÀàËù»ñµÃµÄ´íÎóÐÅÏ¢¶à¡£ÔÚ MFC ÖУ¬ËùÓÐ DAO ´íÎ󶼱í´ïΪ CDaoException ÀàÐ͵ÄÒì³£´íÎó¡£
µ±²¶»ñµ½ÕâÖÖÀàÐ͵ÄÒì³£´íÎóʱ£¬¿ÉÒÔʹÓà CDaoException ³ÉÔ±º¯Êý´ÓÈκδ洢ÔÚÊý¾Ý¿âÒýÇæ Errors ¼¯ºÏÖÐµÄ DAO ´íÎó¶ÔÏóÖмìË÷ÐÅÏ¢¡£Ã¿¸ö´íÎó·¢Éúʱ£¬¶¼»áÓÐÒ»¸ö»ò¶à¸ö´íÎó¶ÔÏó·ÅÈë Errors ¼¯ºÏÖС£µ±ÁíÒ»¸ö DAO ²Ù×÷Éú³É´íÎóʱ£¬Errors ¼¯ºÏ±»Çå³ý£¬ÐµĴíÎó¶ÔÏó±»·ÅÈë Errors ¼¯ºÏ¡£
CDaoFieldExchange ÀàÖ§³ÖÓÉ DAO Êý¾Ý¿âÀàʹÓÃµÄ DAO ¼Ç¼×ֶν»»» (DFX) Àý³Ì¡£Èç¹ûÄúÕýÔÚ±àд×Ô¶¨ÒåÊý¾ÝÀàÐ͵ÄÊý¾Ý½»»»Àý³Ì£¬ÔòʹÓøÃÀࣻ·ñÔò£¬Äú²»»áÖ±½ÓʹÓøÃÀà¡£DFX ÔÚÄú CDaoRecordset ¶ÔÏóµÄ×Ö¶ÎÊý¾Ý³ÉÔ±ºÍÊý¾ÝÔ´Éϵ±Ç°¼Ç¼µÄÏàÓ¦×Ö¶ÎÖ®¼ä½»»»Êý¾Ý¡£DFX ¹ÜÀíÁ½¸ö·½ÏòÖеĽ»»»£¬¼´À´×ÔÊý¾ÝÔ´µÄ½»»»Óëµ½Êý¾ÝÔ´µÄ½»»»¡£ÈôÐè¹ØÓÚ±àд×Ô¶¨Òå DFX Àý³ÌµÄÐÅÏ¢£¬Çë²Î¼û Technical Note 53£¨¿ÉÔÚ Books Online ÖÐµÄ MFC ÏÂÕÒµ½£©¡£
CDaoFieldExchange ¶ÔÏóÌṩ·¢Éú DAO ¼Ç¼×ֶν»»»ËùÐèÒªµÄÉÏÏÂÎÄÐÅÏ¢¡£CDaoFieldExchange ¶ÔÏóÖ§³ÖÐí¶à²Ù×÷£¬°üÀ¨°ó¶¨²ÎÊýºÍ×Ö¶ÎÊý¾Ý³ÉÔ±£¬ÒÔ¼°ÔÚµ±Ç°¼Ç¼µÄ×Ö¶ÎÉÏÉèÖø÷ÖÖ±êÖ¾¡£DFX ²Ù×÷ÊÇÔÚÀàÐ͵ļǼ¼¯ÀàÊý¾Ý³ÉÔ±ÉÏÖ´Ðеģ¬ÕâЩÀàÐÍÓÉ CDaoFieldExchange ÖÐµÄ enum FieldType ¶¨Òå¡£¿ÉÄÜµÄ FieldType ÖµÓУº
ÓÃÓÚ×Ö¶ÎÊý¾Ý³ÉÔ±µÄ CDaoFieldExchange::outputColumn¡£
ÓÃÓÚ²ÎÊýÊý¾Ý³ÉÔ±µÄCDaoFieldExchange::param¡£
ͼ 1 MFC µÄ ODBC Êý¾Ý¿âÀà
ÕâÀïÊÇ»ùÓÚ ODBC µÄÊý¾Ý¿âÀàµÄͼƬ£¬ÓëÄúËùÁ˽âµÄÏàͬ¡£¶¥¶ËµÄÀ¸´ú±í»ùÓÚ ODBC¡¢Óë ODBC ½»Ì¸µÄ MFC Àࡣÿ¸öÊý¾Ý¿âµÄ ODBC Çý¶¯³ÌÐò¶¼½âÊÍ SQL µ÷Ó㬲¢Õë¶Ôÿ¸öÊý¾ÝÔ´¶ÔÆä½øÐÐת»»¡£Ðí¶àÊý¾ÝÔ´¶¼ÓëÏàÓ¦µÄÇý¶¯³ÌÐòÒ»ÆðÏÔʾÔÚ¹ØϵͼµÄµ×²¿£¬ÒÔÌáÐÑÄú ODBC µÄÁé»îÐÔ¡£
ͼ 2 ÊÇ DAO Êý¾Ý¿âÀàµÄͼƬ¡£ËüÃÇͨ¹ýº¬ÓÐ DAO µÄ OLE ½øÐÐͨÐÅ£¬DAO Óë Jet Êý¾Ý¿âÒýÇ潻̸¡£Jet Êý¾Ý¿âÒýÇæÓÐһЩ¶ÀÁ¢µÄ DLL£¬ÓÃÓÚÓë¸÷ÖÖ×ÀÃæÊý¾ÝÔ´½øÐÐͨÐÅ¡£
ͼ 2 MFC DAO Êý¾Ý¿âÀà - ×ÀÃæÊý¾ÝÔ´
Microsoft Jet Êý¾Ý¿âÒýÇæ¿ÉÒÔÖ±½Ó´ò¿ªÖîÈç FoxPro® Êý¾Ý¿âºÍ Paradox µÈµÄÊý¾ÝÔ´¡£µ«Ö»ÒªÄú²»ÐèÒª¸ü¸ÄÕâЩÊý¾ÝÔ´µÄ¼Ü¹¹£¬¾Í¿ÉÒÔ½«ÕâЩ±íÁ´½Óµ½ Microsoft Access Êý¾Ý¿âÖУ¬Êµ¼ÊÉÏÕâ»á¸üÓÐЧ¡£Õâ¾ÍÊÇ FoxPro ºÍ Paradox ±í£¨ËüÃǽöÊÇʾÀý£©ÏÔʾÔÚÁ½¸öλÖõÄÔÒò¡£ÐéÏßÓÃÒÔ°µÊ¾µ±¿ÉÄÜÖ±½Ó´ò¿ªÊý¾ÝԴʱ£¬ËüµÄЧÂÊ»á¸üµÍ¡£
±»Á´½Ó±íµÄÍâ¹Û¼°¹¤×÷·½Ê½Óë Microsoft Jet Êý¾Ý¿âÖеÄÈκÎÆäËü±íÒ»Ñù£¨ËäÈ»ÔÚÁ¬½Óµ½Ô¶³ÌÊý¾ÝºÍ¼ìË÷Ô¶³ÌÊý¾Ý·½ÃæÂÔ΢ÓÐЩÐÔÄܲîÒ죩¡£½¨Á¢ºÍά»¤ÓëÔ¶³ÌÊý¾ÝÔ´Á¬½ÓËùÐèÒªµÄÐÅÏ¢´æ´¢ÔÚ±í¶¨ÒåÖС£
Ïà·´£¬µ±ÄúÖ±½Ó´ò¿ª±íʱ£¬±ØÐëÔÚÿ¸ö»á»°¿ªÊ¼Ê±ÌṩÁ¬½ÓÐÅÏ¢£¬ÒԱ㽨Á¢ÓëÊý¾ÝÔ´µÄÁ¬½Ó¡£½¨Á¢ÓëÔ¶³ÌÊý¾ÝÔ´µÄÁ¬½ÓËùÐèÒªµÄÐÅÏ¢¶¼²»´æ´¢ÔÚ Microsoft Jet Êý¾Ý¿âÖС£ÈôÒªÖ±½Ó´ò¿ª±í£¬¾Í±ØÐëʹÓà CDaoTableDef::Create£¬²¢ÇÒ±ØÐëÌṩÁ¬½ÓÐÅÏ¢£¨ÈçÊý¾ÝÔ´¡¢Óû§Ãû¡¢ÃÜÂëºÍÊý¾Ý¿âÃû³Æ£©¡£
ͼ 3 MFC DAO Êý¾Ý¿âÀ࣬°üÀ¨ SQL Êý¾Ý¿â
Èç¹ûʹÓà DAO Êý¾Ý¿âÀ࣬¾Í¿ÉÒÔ¾ÓÉ ODBC ·ÃÎÊ·þÎñÆ÷ÀàÐ͵ÄÊý¾Ý¿â£¨Èç Microsoft SQL Server ºÍ ORACLE£©¡£Í¼ 3 ²»ÊÇÍêÕûµÄͼƬ£¬ÒòΪËü²¢Ã»ÓаüÀ¨¶ÔËùÓÐÀàÐÍÊý¾ÝÔ´µÄ·ÃÎÊ¡£
×îºó£¬Í¼ 4 ÊǹØÓÚ MFC Êý¾Ý¿âÀàµÄÍêÕûͼƬ¡£Çë×¢Ò⣬MFC À¸ºÍ ODBC À¸ÉϵĴ¹Ö±Ïß±íʾָÅÉÁ½¸öÊý¾Ý¿âÀ༯ÓÃ×÷¡°·Ç´Ë¼´±Ë¡±¾ö²ß¡£Äú¿ÉÒÔÑ¡Ôñ·ÃÎÊËùÓÐÀàÐ͵ÄÊý¾ÝÔ´£¬µ«²»ÄÜ»ìºÏÁ½¸ö¼¯ºÏÖÐµÄ MFC Êý¾Ý¿âÀà¡£
ͼ 4 MFC Êý¾Ý¿âÀà
ODBC Êý¾Ý¿âÀàµÄÊý¾ÝÔ´Ñ¡Ôñ
µ±ÄúÓà MFC ODBC Àà±àдӦÓóÌÐòʱ£¬¿ÉÒÔÁ¬½Óµ½ÈκÎÊý¾ÝÔ´£¨Ö»ÒªÄúÓÐËüµÄ ODBC Çý¶¯³ÌÐò£©¡£ODBC Çý¶¯³ÌÐò¹ÜÀíÆ÷ºÍ ODBC Çý¶¯³ÌÐòµÄ²Ù×÷ÔÚÄúÓÃÕâЩÀà±àдµÄÓ¦ÓóÌÐòÖÐÊÇ͸Ã÷µÄ£¬µ«¸ö±ðÇý¶¯³ÌÐòÐÔÄÜ»áÓ°ÏìÓ¦ÓóÌÐòµÄ¹¦ÄÜ¡£
ͨ³££¬MFC ¶¯Ì¬¼¯£¨µ«²¢·ÇÖ»ÏòÇ°¹ö¶¯µÄ¼Ç¼¼¯£©ÒªÇó ODBC Çý¶¯³ÌÐò¾ßÓÐ 2 ¼¶ API Ò»ÖÂÐÔ¡£Èç¹ûÊý¾ÝÔ´µÄÇý¶¯³ÌÐò·ûºÏ 1 ¼¶ API ÉèÖã¬Äú¾ÍÈÔ¿ÉÒÔʹÓÿɸüÐÂÇÒÖ»¶ÁµÄ¿ìÕÕÓëÖ»ÏòÇ°¹ö¶¯µÄ¼Ç¼¼¯£¬µ«²»ÄÜʹÓö¯Ì¬¼¯¡£È»¶ø£¬Èç¹û 1 ¼¶Çý¶¯³ÌÐòÖ§³ÖÀ©Õ¹µÄÌáÈ¡ºÍ¼ü¼¯Çý¶¯Óα꣬Ëü¾Í¿ÉÒÔÖ§³Ö¶¯Ì¬¼¯¡£
ODBC Desktop Driver Pack 3.0 °æÖ§³Ö 2 ¼¶ ODBC API µ÷Óà SQLExtendedFetch¡£
AppWizard ºÍ ClassWizard »á×Ô¶¯½«Êý¾ÝÔ´µÄÁо²Ì¬µØ°ó¶¨µ½ÄúÓ¦ÓóÌÐòµÄ³ÉÔ±±äÁ¿ÖС£ÕâÊÇÔÚÄúÓ¦ÓóÌÐòÓëÊý¾ÝÔ´Ö®¼ä½¨Á¢Á¬½ÓµÄ×î¼òµ¥µÄ·½·¨£¬µ«²»ÊÇ×îÁé»îµÄ·½·¨¡£¿ÉÒÔÓÃÀà CFieldExchange ½«×Ô¶¨ÒåµÄ¼Ç¼×ֶν»»» (RFX) µ÷ÓÃÌí¼Óµ½ÄúµÄÓ¦ÓóÌÐòÖС£Çë²Î¼û¡°Technical Note 43£ºRFX Routines¡±£¬ÒÔ»ñÈ¡¸ü¶àÐÅÏ¢¡£
ÁíÍ⣬»¹¿ÉÒÔ¿¼ÂǶ¯Ì¬µØ°ó¶¨Êý¾Ý¿âµÄÁС£ÔÚ×îÆÕͨµÄ¼¶±ðÖпÉÖ´ÐÐÏÂÁв½Ö裺
¹¹ÔìÄúµÄÖ÷Òª¼Ç¼¼¯¶ÔÏó¡£È»ºó£¬¿ÉÒÔ½«Ö¸Õë´«µÝ¸øÒ»¸ö´ò¿ªµÄ CDatabase ¶ÔÏ󣬻òÕßÒ²¿ÉÒÔÓÃÆäËü·½·¨ÏòÁмǼ¼¯ÌṩÁ¬½ÓÐÅÏ¢¡£
Ö´ÐÐһЩ²½Ö裬¶¯Ì¬µØÌí¼ÓÁС£
´ò¿ªÄúµÄÖ÷Òª¼Ç¼¼¯¡£
¼Ç¼¼¯»áÑ¡Ôñ¼Ç¼£¬²¢Ê¹ÓüǼ×ֶν»»» (RFX) °ó¶¨¡°¾²Ì¬¡±ÁУ¨Ó³Éäµ½¼Ç¼¼¯×Ö¶ÎÊý¾Ý³ÉÔ±µÄÁУ©ºÍ¶¯Ì¬ÁУ¨Ó³Éäµ½Äú·ÖÅäµÄ¶îÍâ´æ´¢µÄÁУ©¡£
DAO Êý¾Ý¿âÀàµÄÊý¾ÝÔ´Ñ¡Ïî
ÏÖÔÚÎÒÃÇҪ̸µÄÊÇÄú¿ÉÒÔÓà DAO Êý¾Ý¿âÀàÁ¬½ÓµÄÊý¾ÝÔ´¡¢Áеľ²Ì¬°ó¶¨¡¢ÁеĶ¯Ì¬°ó¶¨£¬ÒÔ¼°¼Ç¼µÄË«»º³å¡£
¼ÈÈ» Microsoft Access Êý¾Ý¿âÊÇ Jet µÄ±¾»úÊý¾Ý¿â£¬Äú×ÔÈ»¾Í¿ÉÒÔÒÔ×î¿ìËٶȷÃÎÊËüÃÇ¡£Microsoft Access 97 ¾ßÓеÄÊý¾Ý¿â¸ñʽÊÇ DAO 3.5 °æµÄ±¾»úÊý¾Ý¿â¸ñʽ¡£Èç¹ûʹÓà Microsoft Access 97 Êý¾Ý¿â£¬½«»ñµÃ×îΪ¿ìËÙµÄÐÔÄÜ¡£
Jet ʹÓõ¥¶ÀµÄ DLL Ìṩ¶Ô Microsoft Jet 1.x ºÍ 2.0 °æÊý¾Ý¿âµÄ·ÃÎÊȨÏÞ¡£´æ´¢ÒýÇæºÍ¸ñʽÍêÈ«ÊÇÓà Microsoft Jet 3.0 °æÐÞ¶©µÄ¡£¼ÙÈç¸ü¸ÄÖ®´¦ºÜ¶à£¬Microsoft Jet 3.0 °æ¾Í»á½« 2.0 °æÊý¾Ý¿âÊÓΪÍⲿ ISAM£¬Õâ»áÓ°ÏìÐÔÄÜ¡£Òò´Ë£¬ÕâÒ²ÊÇ´ÙʹÄúÓ¦¸Ã¿¼Âǽ« Microsoft Access Êý¾Ý¿âÉý¼¶µÄºÏÀíÔÒò¡£
ÁíÍ⣬Äú»¹¿ÉÒÔ·ÃÎÊ¿É°²×°µÄ ISAM Êý¾Ý¿âºÍ ODBC Êý¾ÝÔ´¡£ISAM£¨»ùÓÚË÷ÒýµÄÁ¬Ðø·ÃÎÊ·½·¨£©Êý¾Ý¿â£¬Èç FoxPro ºÍ dBASE£¬¿ÉÒÔÖ±½Ó´ò¿ª£¬Ò²¿ÉÒÔÁ´½Óµ½ Access Êý¾Ý¿âÒÔʵÏÖ×î¼ÑÐÔÄÜ¡£ÏÂÃæÊÇ DAO ¿ÉÒÔ·ÃÎʵÄÊý¾ÝÔ´µÄÁÐ±í£º
Microsoft FoxPro µÄ 2.0¡¢2.5 ºÍ 2.6 °æ¡£ÔÚ 3.0 °æÖпÉÒÔµ¼ÈëÓëµ¼³öÊý¾Ý£¬µ«²»ÄÜ´´½¨¶ÔÏó¡£
dBASE III¡¢dBASE IV ºÍ dBASE 5.0
Paradox µÄ 3.x¡¢4.x ºÍ 5.x °æ
Btrieve µÄ 5.1x ºÍ 6.0 °æ
Microsoft Excel µÄ 3.0¡¢4.0¡¢5.0¡¢7.0 ºÍ 8.0 °æ¹¤×÷±í
Lotus WKS¡¢WK1¡¢WK3¡¢WK4 µç×Ó±í¸ñ
Îı¾Îļþ
Çë¼Çס£¬Microsoft Access µÄ 1.x¡¢2.0 ºÍ 7.0 °æÊý¾Ý¿â¶¼ÊôÓÚ´ËÀà±ð¡£
¿ÉÒÔͨ¹ý ODBC ·ÃÎÊ ODBC Êý¾ÝÔ´£¬Èç SQL Server ºÍ Oracle£¬Òò´ËÄú¿ÉÒÔÑ¡ÔñÕë¶ÔÕâЩÊý¾ÝԴʹÓà DAO¡£Ò»¸ö ODBC Êý¾ÝÔ´¿ÉÒÔÀ´×ÔÈκΠDBMS£¬Ö»ÒªÄúÓµÓиà DBMS µÄÊʵ±µÄ ODBC Çý¶¯³ÌÐò¡£¶ÔÓÚ Visual C++ 2.0 °æ»ò¸ü¸ß°æ±¾£¬ÄúÐèÒª 32 λµÄ ODBC Çý¶¯³ÌÐò£¨µ« Win32 ³ýÍ⣬ÔÚ Win32 ÖÐÐèÒª 16 λµÄ ODBC Çý¶¯³ÌÐò£©¡£ÏÂÃæÊÇ´Ë°æ±¾ Visual C++ Ëù°üº¬µÄ ODBC Çý¶¯³ÌÐòÁÐ±í¡£
SQL Server
Microsoft Access
Microsoft FoxPro
Microsoft Excel
dBASE
Paradox
Îı¾Îļþ
Microsoft Desktop Database Drivers 3.0 °æ£¨Ëü°üº¬ÁбíÖеÄ×îºóÁùÏΪÕâЩÊý¾ÝÔ´Ìṩ×î¼ÑÐÔÄÜ¡£ÕâЩֻÏÞ 32 λÇý¶¯³ÌÐò¡£
½«ÍⲿÊý¾ÝÔ´£¨Èç SQL Server£©Á´½Óµ½ Microsoft Access ±íÊÇ×îÓÐЧµÄ´¦ÀíÊý¾Ý·ÃÎʵķ½·¨¡£ÔÚ½«Ó¦ÓóÌÐòÁ¬½Óµ½Ô¶³ÌÊý¾ÝÔ´ÒÔÇ°£¬±ØÐëÏÈÈ·±£Ó¦ÓóÌÐòµÄÓû§¿ÉÒÔ·ÃÎÊÔ¶³ÌÊý¾Ý£¬²¢ÇÒÈ·±£ÕýÈ·µØÉè¼ÆÄúµÄÓ¦ÓóÌÐò£¬ÒÔ½â¾öÔ¶³ÌÊý¾ÝÔ´°²È«ÐÔÄÑÌâ¡£ÁíÍ⣬Äú»¹±ØÐëÈ·±£Ó¦ÓóÌÐòÄܹ»ÕýÈ·µØÓëÇø·Ö´óСдµÄÊý¾ÝÔ´½øÐн»Á÷£¬²¢ÇÒÈ·±£ÕýÈ·µØ³õʼ»¯¿É°²×°µÄ ISAM£¬ÒÔÓÃÓÚÄúÏë·ÃÎʵÄÊý¾ÝÔ´¡£×îºó£¬Äú±ØÐë¼ì²éÄúµÄ´úÂ룬ÒÔÈ·±£ÔÚ·ÃÎÊ·Ç Jet Êý¾ÝԴʱ£¬´úÂëûÓÐʹÓà Microsoft Jet Êý¾ÝԴרÓõĶÔÏó»òµ÷Óá£
ÉèÖÃÁ´½Ó×î¼ò½ÝµÄ·½·¨ÊÇ£º½øÈë Microsoft Access¡£Èç¹ûÓõÄÊÇ Microsoft Access 2.0 °æ£¬ÔòʹÓá°Îļþ¡±/¡°¸½¼Ó±í¡±ÃüÁÈç¹ûÓõÄÊÇ Microsoft Access 95 ºÍ Microsoft Access 97£¬ÔòʹÓá°Îļþ¡±/¡°»ñÈ¡ÍⲿÊý¾Ý¡±/¡°Á´½Ó±í¡±ÃüÁî¡£
Á¬½ÓÐÅÏ¢´æ´¢ÔÚÄúËùʹÓõĻù±¾±í (.MDB) ÖС£Èç¹ûÒƶ¯ÁËÍⲿÊý¾ÝµÄλÖ㬾ͱØÐëÔÚ Microsoft Access Öлò´Ó´úÂëÖе÷Óà CDaoTableDef::RefreshLink£¬ÖØн¨Á¢Á´½Ó¡£
DAO ¼Ç¼×ֶν»»»»úÖÆÓëÔÚ»ùÓÚ ODBC µÄÊý¾Ý¿âÀàÖÐµÄ RFX ÓÐ×ÅÏàͬµÄ¹¤×÷·½Ê½¡£¼Ç¼¼¯¶ÔÏóµÄ×Ö¶ÎÊý¾Ý³ÉÔ±Èç¹ûÁªÏµÔÚÒ»Æ𣬾ÍÐγÉÒ»¸ö¡°±à¼»º³åÇø¡±£¬ÒÔ±£´æÒ»¸ö¼Ç¼µÄÑ¡¶¨ÁС£µ±¼Ç¼¼¯µÚÒ»´Î´ò¿ª²¢Òª¶ÁÈ¡µÚÒ»Ìõ¼Ç¼ʱ£¬DFX ¾Í»á½«Ã¿¸öÑ¡¶¨ÁÐÓëÊʵ±×Ö¶ÎÊý¾Ý³ÉÔ±µÄµØÖ·°ó¶¨£¨¹ØÁª£©ÔÚÒ»Æð¡£µ±¼Ç¼¼¯¸üÐÂÒ»Ìõ¼Ç¼ʱ£¬DFX µ÷Óà DAO ÒÔÏòÊý¾Ý¿âÒýÇæ·¢ËÍÊʵ±µÄÃüÁî¡£DFX ÀûÓÃËü¶Ô×Ö¶ÎÊý¾Ý³ÉÔ±ËùÁ˽âµÄÄÚÈÝ£¬Ö¸¶¨ÒªÐ´ÈëµÄÊý¾ÝÔ´ÖеÄÁУ¨×ֶΣ©¡£
Ïòµ¼Ö§³ÖÁеľ²Ì¬°ó¶¨¡£Äú¿ÉÒÔÌí¼Ó×Ô¼ºµÄ DFX µ÷Ó㬾ÍÏóʹÓûùÓÚ ODBC µÄÀàʱÄÇÑù¡£Ê×ÏÈ£¬¶ÔÓÚÿ¸ö°ó¶¨×ֶκͲÎÊý£¬¶¼±ØÐ뽫³ÉÔ±Ìí¼Óµ½ CDaoRecordset ÅÉÉúµÄÀàÖС£½ÓÏÂÀ´£¬CDaoRecordset::DoFieldExchange Ó¦±»Ìæ´ú¡£Çë×¢Ò⣬³ÉÔ±µÄÊý¾ÝÀàÐͺÜÖØÒª¡£ËüÓ¦ÓëÀ´×ÔÊý¾Ý¿â×Ö¶ÎÖеÄÊý¾ÝÆ¥Å䣬»òÕßÖÁÉÙ¿Éת»»³ÉÄÇÖÖÀàÐÍ¡£MFC Technical #53 ¸üÏêϸµØ½²ÊöÁ˴˹ý³Ì¡£
CDaoFieldExchange ÀàÖ§³ÖÓÉ DAO Êý¾Ý¿âÀàʹÓÃµÄ DAO ¼Ç¼×ֶν»»» (DFX) Àý³Ì¡£Èç¹ûÄúÕýÔÚ±àд×Ô¶¨ÒåÊý¾ÝÀàÐ͵ÄÊý¾Ý½»»»Àý³Ì£¬ÔòʹÓøÃÀà¡£CDaoFieldExchange ¶ÔÏóÌṩ·¢Éú DAO ¼Ç¼×ֶν»»»ËùÐèÒªµÄÉÏÏÂÎÄÐÅÏ¢¡£CDaoFieldExchange ¶ÔÏóÖ§³ÖÐí¶à²Ù×÷£¬°üÀ¨°ó¶¨²ÎÊýºÍ×Ö¶ÎÊý¾Ý³ÉÔ±£¬ÒÔ¼°ÔÚµ±Ç°¼Ç¼µÄ×Ö¶ÎÉÏÉèÖø÷ÖÖ±êÖ¾¡£
DAO Êý¾Ý¿âÀàÖеĶ¯Ì¬°ó¶¨
Èç¹û¿ÉÒÔÓûùÓÚ ODBC µÄÀද̬°ó¶¨ÁУ¬¶ÔÕâÖÖÐÐΪµÄÖ§³Ö¾Í²»»áÄÚÖÃÓÚ MFC ÀàÖС£¶¯Ì¬°ó¶¨»áÄÚÖÃÔÚ DAO Êý¾Ý¿âÀàÖУ¬¶øÇÒÖ´ÐÐÆðÀ´Ï൱ÈÝÒס£
»¹¿ÉÒÔ×öһЩÆäËüµÄÊÂÇéÒÔÓÅ»¯ÐÔÄÜ£¬Èç¼ìË÷¼Ç¼µÄÒ»²¿·Ö¶ø²»ÊÇÕû¸ö¼Ç¼¡£ÔÚ±¾³ÂÊöµÄÉԺ󲿷ÖÖУ¬ÎÒÃǽ«ÌṩһЩ¿ÉÒÔÓÅ»¯Ó¦ÓóÌÐòµÄ·½·¨¡£
DFX ºÍ¶¯Ì¬°ó¶¨²»ÊÇ»¥ÏàÅųâµÄÑ¡Ôñ·½°¸¡£Í¨¹ý DAO Êý¾Ý¿âÀ࣬¿ÉÒÔ½«¾²Ì¬ºÍ¶¯Ì¬°ó¶¨µ÷ÓûìºÏ£¬ÒÔʵÏÖ×î´óЧÂÊ¡£
DAO Êý¾Ý¿âÀàÖеÄË«»º³å
ÔÚ MFC µÄ CDaoRecordset ÀàÖУ¬Ë«»º³åÊÇÒ»ÖÖµ±¼Ç¼¼¯Äڵĵ±Ç°¼Ç¼·¢Éú¸ü¸Äʱ¼ò»¯¼ì²âµÄ»úÖÆ¡£µ±Ìí¼ÓмǼºÍ±à¼ÏÖÓмǼʱ£¬¶ÔÄúµÄ DAO ¼Ç¼¼¯Ê¹ÓÃË«»º³å»á¼õÉÙ±ØÐèµÄ¹¤×÷Á¿¡£Ä¬ÈÏÇé¿öÏ£¬ÄúµÄ MFC DAO ¼Ç¼¼¯±£Áô±à¼»º³åÇøµÄµÚ¶þ·Ý¸±±¾£¨¼Ç¼¼¯ÀàµÄ×Ö¶ÎÊý¾Ý³ÉÔ±£¬È«Ì帴ÖÆ£»DAO¡°°ïÖú¡±ÖгÆÏàÓ¦µÄ»º³åÇøΪ¡°¸´ÖÆ»º³åÇø¡±£©¡£µ±Äú¶ÔÊý¾Ý³ÉÔ±½øÐиü¸Äʱ£¬MFC »áÄÃËüÃÇÓ븱±¾£¨¡°Ë«»º³åÇø¡±£©½øÐбȽÏÒÔ¼ì²â¸ü¸Ä¡£
Ë«»º³åµÄ´úÓ÷½·¨ - ²»±£ÁôÊý¾ÝµÄ¸±±¾ - µ±±à¼µ±Ç°¼Ç¼µÄ×Ö¶Îʱ£¬ÒªÇóÄú½øÐÐÆäËüº¯Êýµ÷Óá£
Ë«»º³åÒ»Ö±ÊÇ»ùÓÚ ODBC µÄÊý¾Ý¿âÀàµÄÒ»²¿·Ö¡£¶ÔÓÚ DAO Êý¾Ý¿âÀ࣬Èç¹ûÐèÒª£¬Äú¿ÉÒÔÍ£ÓøûúÖÆÒÔÌá¸ßЧÂÊ¡£
¸Ã»úÖƵÄÖ÷¿ª¹ØÃûΪ m_bCheckCacheForDirtyFields£¬Dirty Òâ˼ÊÇ¡°ÒѸü¸Ä¡±¡£Èç¹û½«´Ë¿ª¹ØÖÃÓÚ ON£¨¿ª£©£¬¾Í¿ÉÒÔ¶ÔÈ«²¿»ò²¿·Ö×Ö¶ÎÆôÓÃË«»º³å¡£Èç¹û¸ÃÖ÷¿ª¹ØÊÇ OFF£¨¹Ø£©£¬¾Í»á½ûÓÃÕû¸öË«»º³å»úÖÆ¡£
Äú×îÏë¹Ø±ÕÆäË«»º³åµÄ×ֶΰüÀ¨±¸×¢×ֶΡ¢Í¼Æ¬×ֶΣ¬ÒÔ¼°ÆäËü BLOB£¨´óÐͶþ½øÖƶÔÏ󣩡£
DAO SDK Àà
DAO SDK Öк¬ÓÐһЩ C++ Êý¾Ý¿âÀ࣬ÕâЩÀà±Ë´Ë¶ÀÁ¢£¬¶øÇÒ²»Í¬ÓÚ MFC DAO Êý¾Ý¿âÀà¡£ÕâЩ C++ Àཫµ¥¸ö¶ÔÏó·â×°µ½ DAO ²ã´Î½á¹¹ÖС£ËäÈ»Äú¿ÉÒÔ½« DAO SDK C++ ÀàÓë MFC DAO Êý¾Ý¿âÀà»ìºÏ£¬µ« DAO SDK C++ À಻×ñѲÙ×÷·û³¬ÔØµÄ MFC ×¼Ôò£¬²¢ÇÒÔÚ»ìºÏʹÓÃÕâЩÀàʱÄú±ØÐëµ±ÐÄ¡£ÓйصÄÏêϸÐÅÏ¢£¬Çë²ÎÔÄ Microsoft Systems Journal£¨1999 Äê 6 Ô£©ÖеÄÎÄÕ¡°The DAO of Databases£ºUsing Data Access Objects and the Jet Engine in C++¡±¡£
ϱí±È½ÏÁË DAO SDK ÀàµÄ¹¦ÄÜÓë MFC DAO Êý¾Ý¿âÀàµÄ¹¦ÄÜ¡£ DAO SDK Êý¾Ý¿âÀà
MFC DAO Êý¾Ý¿âÀà
´Ó Visual Basic ½øÐмòµ¥µÄǨÒÆ
´Ó MFC ODBC Êý¾Ý¿âÀà½øÐмòµ¥µÄǨÒÆ
Ö±½ÓÓ³Éäµ½ DAO µÄ OLE ×Ô¶¯»¯¶ÔÏó
·ûºÏ MFC ±ê×¼Á½Ïà½á¹¹
¸ü¶àµÄ Jet/DAO ¹¦ÄÜ
Ö§³Ö AppWizard ºÍ ClassWizard
²»·ûºÏ MFC ±ê×¼Á½Ïà½á¹¹
Òþ²Ø¸üÀ§ÄÑµÄ DAO ¹¦ÄÜ
¶ÔÄÇЩÓùßÁË Visual Basic µÄÈ˶øÑÔ£¬Ê¹Óà DAO SDK ÀàÊǸüÈÝÒ×ʵÏÖµÄת»»£¬µ«Ëü²»·ûºÏ MFC¡£ÄÇЩÒѾʹÓà MFC ODBC Êý¾Ý¿âÀàµÄ¿ª·¢ÈËÔ±Ôò»á·¢ÏÖ£¬MFC DAO ÀàµÄÌåϵ½á¹¹ºÍÓ÷¨¶ÔËûÃÇÀ´ËµºÜÊìϤ¡£
±È½Ï MFC Êý¾Ý¿âÀà
ÎÒÃDz»·ÁÊ×ÏÈÖصãÌÖÂÛÁ½¸öÀ༯ÄÚ¹²Í¬µÄÊý¾Ý¿â¹¦ÄÜ¡£
¶þÕ߶¼Ö§³Ö¶Ô¼Ç¼¼¯½øÐйö¶¯
ODBC ÀàÒÀÀµÓÚ»ù´¡Çý¶¯³ÌÐò¡£
DAO ÀàÄܸüºÃµØÖ§³Ö MDB£¬¶Ô¿É°²×°µÄ ISAM ÓÐÒ棻²¢ÇÒ¶Ô»ùÓÚ·þÎñÆ÷µÄÊý¾Ý£¬DAO ÀàÓë ODBC Êý¾Ý¿âÀàµÄÖ§³Ö³Ì¶ÈÏàͬ¡£
¶þÕ߶¼Ö§³ÖÊÂÎñ
ÔÚ Database£¨Êý¾Ý¿â£©¼¶±ðµÄ ODBC Àà¡£
ÔÚ Workspace£¨¹¤×÷Çø£©¼¶±ðµÄ DAO Àà¡£
¼Ç¼¼¯¸üй¦Äܼ¸ºõÏàͬ¡£
¶þÕ߶¼Ö§³ÖÔÚ¸üÐÂÆÚ¼äËø¶¨¼Ç¼¡£
Á½¸öÀ༯¶¼Ö§³Ö×Ö¶ÎÊý¾Ý¸ü¸ÄµÄ¼ì²â¡£
¶þÕ߶¼ÓÐ Move ²Ù×÷¡£
CDatabase ºÍ CDaoDatabase ¶¼¿É¼ì²âÊý¾ÝÔ´ÊÇ·ñ½ÓÊÜÊÂÎñ¡£×Ô´Ó MFC 4.2 ¿ªÊ¼£¬ODBC Êý¾Ý¿âÀàÖеÄÊÂÎñÒªÇó¾ÍÏ൱¿íËÉÁË¡£
Á½ÖÖÊý¾Ý¿â¶ÔÏó¶¼ÔÊÐíÄúÉèÖÃÔ¤¶¨ÒåµÄ²éѯ³¬Ê±Ê±ÆÚ¡£
¶þÕ߶¼¿ÉÒÔÖ´ÐÐÖ±½ÓµÄ SQL Óï¾ä¡£
ODBC Êý¾Ý¿âÀàµÄÆäËü¹¦ÄÜ
×Ô´Ó MFC 4.2 ¿ªÊ¼£¬ODBC Êý¾Ý¿âÀà¾ÍÊǶàÏ̵߳ġ£ÈôÒªÀûÓôËÐÔÄÜ£¬¾Í±ØÐëʹÓöàÏß³ÌµÄ ODBC Çý¶¯³ÌÐò¡£DAO Õý¿ª·¢³Éµ¥ÔªỊ̈߳¬µ«ÉÐδȷ¶¨ºÎʱÄÜͶÈëʹÓá£
ÔÚ MFC 4.2 ÖУ¬´óÁ¿ÐÐÌáÈ¡¹¦ÄÜÊÇй¦ÄÜ£¬ÁíÍ⻹Ìí¼ÓÁËÌØÊâµÄµ¼º½ÄÜÁ¦¡£
ÔÚÕë¶ÔÐí¶àÎÊÌâµÄ½â´ðÖУ¬ÎÒÃÇÒѾ¶Ô¿ØÖÆ̨Êý¾Ý¿âÓ¦ÓóÌÐò¸øÓèÁ˸üºÃµÄÖ§³Ö¡£CDatabase::OpenEx ÖеÄÐÂÑ¡ÏîÓУº
CDatabase::noOdbcDialog ÎÞÂÛÌṩµÄÁ¬½ÓÐÅÏ¢ÊÇ·ñ×ã¹»£¬¶¼²»ÏÔʾ ODBC Á¬½Ó¶Ô»°¿ò¡£
CDatabase::forceOdbcDialog ×ÜÊÇÏÔʾ ODBC Á¬½Ó¶Ô»°¿ò¡£
DAO Êý¾Ý¿âÀàµÄÆäËü¹¦ÄÜ
Workspace¡¢TableDef ºÍ QueryDef ¶ÔÏó¾ùÊÇ DAO Êý¾Ý¿âÀàËù¶ÀÓеġ£ÔÚ ODBC Êý¾Ý¿âÀàÖÐûÓÐÕâЩ¶ÔÏóµÄÖ±½ÓµÈ¼Û¶ÔÏó¡£
CDaoTableDef ºÍ CDaoQueryDef ¹¦ÄÜͨ³£¿ÉÒÔͨ¹ýÖ±½ÓµÄ ODBC µ÷ÓöøÖظ´Ê¹Óã¨Èç CATALOG2 ʾÀýÖÐËùʾµÄµ÷Óã©¡£
CDaoDatabase Ö§³Ö TableDef¡¢QueryDef ºÍ Relation µÄ´´½¨¡£
CDaoRecordset ¾ßÓиüÇ¿µÄµ¼º½¹¦ÄÜ
Find ²Ù×÷
°Ù·Ö±ÈλÖÃ
Seek
´óÁ¿¼Ç¼ÌáÈ¡¹¦ÄܺÍÏà¹ØµÄ¸ßËÙ»º³å¶¼ÊÇÄÚÖõÄ
ÔÚÔËÐÐʱÓà CDaoTableDef ¶ÔÏó´´½¨×ֶκÍË÷ÒýµÄÄÜÁ¦ÊǼ«¼ÑÓÅÊÆ£¬Õâ¿ÉÓÃÓÚ¶ÔÖ§³ÖËüµÄÊý¾ÝÔ´½øÐÐÈ·ÈÏ¡£
CDaoQueryDefs ¿ÉÒÔͨ¹ýʹÓÃ×ֶκÍË÷Òý¶ø´´½¨£¬²¢¿É´æ´¢ÆðÀ´ÒÔ±¸Öظ´Ê¹Óá£
CDaoQueryDefs »¹¿ÉÒÔ¿ØÖÆ ODBC ³¬Ê±¡£
ÓÅ»¯ÄúµÄ MFC Êý¾Ý¿âÓ¦ÓóÌÐò
ÓÐһЩÃ÷ÏÔµ«³£±»ºöÂԵķ½·¨¿ÉÒԸĽøÓ¦ÓóÌÐòµÄÐÔÄÜ¡£ÀýÈ磬²éÃ÷ÄúµÄÍøÂçÔõÑù²ÅÄÜÔöÇ¿»ò·Á°Êý¾Ý¼ìË÷£¨ÈçÒì²½²éѯ£©¡£
ÄúËùÓµÓÐµÄ ODBC Çý¶¯³ÌÐòµÄÀàÐÍ¿ÉÄÜÒ²»áÓ°ÏìÍøÂçµÄÐÔÄÜ¡£
µ¥¼¶Çý¶¯³ÌÐòÓÃÓÚÄÇЩ²»»ùÓÚ SQL µÄÊý¾Ý¿â¡£ÆäÊý¾Ý¿âÎļþÖ±½ÓÓɸÃÇý¶¯³ÌÐò´¦Àí¡£¸ÃÇý¶¯³ÌÐò´¦Àí SQL Óï¾ä²¢´ÓÊý¾Ý¿âÖмìË÷ÐÅÏ¢¡£SQL Óï¾äÒ»¾·ÖÎöÓëת»»ºó£¬¾Í×÷Ϊ»ù±¾Îļþ²Ù×÷´«¸øÊý¾Ý¿â¡£´¦Àí xBASE ÎļþµÄÇý¶¯³ÌÐòÊÇÖ´Ðе¥¼¶Çý¶¯³ÌÐòµÄÒ»¸öʾÀý¡£
µ¥¼¶Çý¶¯³ÌÐò¿ÉÄÜ»áÏÞÖÆ¿ÉÌá½»µÄ SQL Óï¾ä¼¯ºÏ¡£µ¥¼¶Çý¶¯³ÌÐò±ØÐëÖ§³ÖµÄ×îС SQL Óï¾ä¼¯ºÏÊÇÔÚ¸½Â¼ C¡°SQL Óï·¨¡±ÖÐµÄ ODBC SDK¡¶³ÌÐòÔ±Ö¸ÄÏ¡·Öж¨ÒåµÄ¡£
µ¥¼¶Çý¶¯³ÌÐòͨ³£Òª±ÈʹÓñ¾»ú DBMS ¹¤¾ß£¨Èç Microsoft FoxPro£©ÂýһЩ£¬ÒòΪËüÃÇÒª·ÖÎö SQL Óï¾ä·ÖÎö²¢½«Æäת»»³É»ù±¾Îļþ²Ù×÷¡£ËüÃÇÂýµ½Ê²Ã´³Ì¶ÈÈ¡¾öÓڸýø³ÌµÄÓÅ»¯³Ì¶È¡£Á½¸ö²»Í¬µ¥¼¶Çý¶¯³ÌÐòÖ®¼äµÄËٶȲîÒìͨ³£Òª¹éÒòÓÚÓÅ»¯µÄ·½·¨¡£
Ôڶ༶ÅäÖÃÖУ¬Çý¶¯³ÌÐò½«ÇëÇó·¢Ë͵½´¦ÀíÕâЩÇëÇóµÄ·þÎñÆ÷¡£ÇëÇó²ÉÓõĸñʽ¿ÉÄÜÊÇ SQL »ò DBMS רÓõĸñʽ¡£ËäÈ»Õû¸ö°²×°¿ÉÒÔÔÚÒ»¸öϵͳÉÏÍê³É£¬µ«¸ü³£¼ûµÄÔòÊÇ·Ö²¼µ½¸÷¸öƽ̨ÖС£Í¨³££¬Ó¦ÓóÌÐò¡¢Çý¶¯³ÌÐòºÍÇý¶¯³ÌÐò¹ÜÀíÆ÷¾ùפÁôÔÚÒ»¸öϵͳÉÏ£¬³ÆΪ¿Í»§¶Ë¡£¶øÊý¾Ý¿âºÍ¿ØÖƶÔÊý¾Ý¿â·ÃÎʵÄÈí¼þÔòפÁôÔÚÁíÒ»¸öϵͳÉÏ£¬³ÆΪ·þÎñÆ÷¡£ÓÐÁ½ÖÖÀàÐ͵Ķ༶Çý¶¯³ÌÐò£ºÁ½¼¶ºÍÈý¼¶£¨»òÍø¹Ø£©¡£ÓйصÄÏêϸÐÅÏ¢£¬Çë²Î¼û Colleen Lambert µÄÎÄÕ¡°ODBC£ºArchitecture£¬Performance£¬and Tuning¡±£¨Î»ÓÚ Microsoft Developer Network ¹âÅÌ£©¡£
ÓÅ»¯ ODBC Êý¾Ý¿âºÍ¼Ç¼¼¯¶ÔÏó
µ±Äú´ò¿ª CDatabase ¶ÔÏóʱ£¬¾Í¿ÉÒÔÌṩÊý¾ÝÔ´Ãû³Æ»ò NULL ÒÔÏòÓû§ÏÔʾѡÔñ¶Ô»°¿ò¡£MFC ODBC Êý¾Ý¿âÀ಻֧³Ö¶ÔÊý¾Ý¿âµÄÅÅËüÐÔ·ÃÎÊ£¬Òò´ËÁ¬½Ó×ÜÊǹ²ÏíµÄ¡£µ«ÊÇ£¬Äú¿ÉÒÔÒÔÖ»¶Á·½Ê½´ò¿ªÊý¾Ý¿â¡£Çë¼Çס£¬Èç¹ûÕâÑù×ö£¬ÔòËùÓдӸà CDatabase ¶ÔÏóÅÉÉúµÄ¼Ç¼¼¯½«Ò²ÊÇÖ»¶ÁµÄ¡£ÏÂÃæµÄÑ¡Ïî¿ÉʹµÃ¿ØÖÆ̨ӦÓóÌÐòµÄ±àд¸üΪÈÝÒס£ÕâЩÐÂÑ¡ÏîÊÇÓû§×î³£ÇëÇóµÄ¡£
CDatabase::noOdbcDialog ÎÞÂÛÌṩµÄÁ¬½ÓÐÅÏ¢ÊÇ·ñ×ã¹»£¬¶¼²»ÏÔʾ ODBC Á¬½Ó¶Ô»°¿ò¡£
CDatabase::forceOdbcDialog ×ÜÊÇÏÔʾ ODBC Á¬½Ó¶Ô»°¿ò¡£
Äú¿ÉÒÔÑ¡Ôñ½« ODBC Óαê¿âÓëÄúµÄÓ¦ÓóÌÐò×°Ôص½Ò»Æ𡣸ù¾Ý»ù´¡Çý¶¯³ÌÐòµÄÐÔÄÜ£¬ÄúÒ²¿ÉÄܲ»ÐèÒªËü¡£Óαê¿â¿ÉÑڲػù´¡ ODBC Çý¶¯³ÌÐòµÄijЩ¹¦ÄÜ£¬´Ó¶øÓÐЧµØ·ÀֹʹÓö¯Ì¬¼¯£¨Èç¹ûÇý¶¯³ÌÐòÖ§³ÖËüÃÇ£©¡£Èç¹û×°ÔØÁËÓαê¿â£¬½«Ö»Ö§³Ö¾²Ì¬¿ìÕպ͡°forwardOnly¡±Óαꡣ
Ëù´ò¿ªµÄ CRecordset ¶ÔÏóµÄÀàÐͽ«¶ÔÓ¦ÓóÌÐòÐÔÄÜÓкܴóÓ°Ïì¡£Èç¹ûÄúÏëÈö¯Ì¬¼Ç¼¼¯ÊµÏÖË«Ïò¹ö¶¯£¬ÇëÑ¡Ôñ CRecordset::dynaset ÀàÐÍ¡£ÈôÏëÈþ²Ì¬¼Ç¼¼¯ÊµÏÖË«Ïò¹ö¶¯£¬ÇëÑ¡Ôñ CRecordset::snapshot ÀàÐÍ¡£Èç¹û²»ÐèÒª¶ÔÊý¾Ý½øÐÐÀ´»Ø¹ö¶¯£¬ÇëÑ¡Ôñ CRecordset::forwardOnly ÀàÐÍ£¬ÕâÑù»á´´½¨Ò»¸öÖ»ÄÜÏòÇ°¹ö¶¯µÄÖ»¶Á¼Ç¼¼¯¡£Ð嵀 CRecordset::dynamic ÀàÐͼǼ¼¯ÊÇÒ»¸ö¿ÉË«Ïò¹ö¶¯µÄ¼Ç¼¼¯¡£ÔÚ½øÐÐÌáÈ¡²Ù×÷ºó£¬ÆäËûÓû§¶Ô³ÉÔ±Éí·Ý¡¢ÅÅÐòÒÔ¼°Êý¾ÝÖµËù×öµÄ¸ü¸Ä¶¼ÊǿɼûµÄ¡£µ«ÊÇÇë×¢Ò⣬Ðí¶à ODBC Çý¶¯³ÌÐò²»Ö§³ÖÕâÖÖÀàÐ͵ļǼ¼¯¡£
CRecordset µÄÆäËüÑ¡ÏîÓУº
CRecordset::none δÉèÖÃÈκÎÑ¡ÏĬÈÏÇé¿öÏ£¬¿ÉÒÔÓà Edit »ò Delete ¶Ô¼Ç¼¼¯½øÐиüУ¬¶øÇÒÔÊÐíÓà AddNew ×·¼ÓмǼ¡£¿É¸üÐÂÐÔ²»½öÈ¡¾öÓÚÊý¾ÝÔ´£¬Ò²È¡¾öÓÚÄúÖ¸¶¨µÄÑ¡Ïî¡£
CRecordset::appendOnly ²»ÔÊÐíÔڼǼ¼¯ÉϽøÐÐ Edit »ò Delete ²Ù×÷¡£Ö»ÔÊÐíʹÓà AddNew¡£
CRecordset::readOnly ÒÔÖ»¶Á·½Ê½´ò¿ª¼Ç¼¼¯¡£
CRecordset::optimizeBulkAdd ʹÓÃÒÑ×¼±¸ºÃµÄ SQL Óï¾ä£¬Ò»´ÎÓÅ»¯Ìí¼Ó¶à¸ö¼Ç¼µÄ²Ù×÷¡£¸ÃÑ¡ÏîÓë CRecordset::useMultiRowFetch ÊÇ»¥³âµÄ¡£
CRecordset::useMultiRowFetch Ö´ÐдóÁ¿ÐÐÌáÈ¡£¬ÒÔÔÊÐíÔÚÒ»¸öÌáÈ¡²Ù×÷ÖмìË÷¶àÐС£¸ÃÑ¡ÏîÓë CRecordset::optimizeBulkAdd ÊÇ»¥³âµÄ¡£Çë×¢Ò⣬Èç¹ûÖ¸¶¨ CRecordset::useMultiRowFetch£¬Ôò»á×Ô¶¯¿ªÆôÑ¡Ïî CRecordset::noDirtyFieldCheck£¨Ë«»º³å½«²»¿ÉÓã©£»ÔÚÖ»ÏòÇ°¹ö¶¯¼Ç¼¼¯ÉÏ£¬½«×Ô¶¯¿ªÆôÑ¡Ïî CRecordset::useExtendedFetch¡£
CRecordset::skipDeletedRecords ÔڼǼ¼¯ÄÚµ¼º½Ê±Ìø¹ýÒÑɾ³ýµÄ¼Ç¼¡£Õâ»á½µµÍijЩÏà¹ØÌáÈ¡µÄÐÔÄÜ¡£¸ÃÑ¡ÏîÔÚÖ»ÏòÇ°¹ö¶¯¼Ç¼¼¯ÉÏÎÞЧ¡£Çë×¢Ò⣬CRecordset::skipDeletedRecords Óë¡°Çý¶¯³ÌÐò°ü×°¡±ÀàËÆ£¬ÕâÒâζ×Åɾ³ý¹ýµÄÐÐÒѴӼǼ¼¯ÄÚɾµôÁË¡£
CRecordset::useBookmarks Èç¹ûÖ§³ÖµÄ»°£¬¿ÉÒÔÔڼǼ¼¯ÉÏʹÓÃÊéÇ©¡£ÊéÇ©»á½µµÍÊý¾Ý¼ìË÷µÄËٶȣ¬µ«»á¸Ä½øÊý¾Ýµ¼º½µÄÐÔÄÜ¡£ÔÚÖ»ÏòÇ°¹ö¶¯¼Ç¼¼¯ÉÏÊéÇ©ÎÞЧ¡£
CRecordset::noDirtyFieldCheck ¹Ø±Õ×Ô¶¯µÄ Dirty ×ֶμì²é£¨Ë«»º³å£©¡£Õ⽫¸Ä½øÐÔÄÜ£»µ«Äú±ØÐëͨ¹ýµ÷ÓÃSetFieldDirty ºÍ SetFieldNull ³ÉÔ±º¯Êý£¬ÊÖ¹¤½«×ֶαê־Ϊ Dirty¡£
CRecordset::executeDirect ²»Ê¹ÓÃÒÑ×¼±¸ºÃµÄ SQL Óï¾ä¡£ÔÚÐè¸Ä½øÐÔÄÜʱ£¬Èç¹û²»µ÷Óà Requery ³ÉÔ±º¯Êý£¬¾ÍÇëÖ¸¶¨¸ÃÑ¡Ïî¡£
CRecordset::useExtendedFetch Ö´ÐÐ SQLExtendedFetch ¶ø²»ÊÇ SQLFetch¡£ÕâÊÇÓÃÓÚÔÚÖ»ÏòÇ°¹ö¶¯¼Ç¼¼¯ÉÏÖ´ÐдóÁ¿ÐÐÌáÈ¡¶øÉè¼ÆµÄ¡£Èç¹ûÔÚÖ»ÏòÇ°¹ö¶¯¼Ç¼¼¯ÉÏÖ¸¶¨Ñ¡Ïî CRecordset::useMultiRowFetch£¬Ôò»á×Ô¶¯¿ªÆô CRecordset::useExtendedFetch¡£
CRecordset::userAllocMultiRowBuffers Óû§½«ÎªÊý¾Ý·ÖÅä´æ´¢»º³åÇø¡£Èç¹ûÏë×Ô¼º·ÖÅä´æ´¢Á¿£¬Ó¦½«¸ÃÑ¡ÏîÓë CRecordset::useMultiRowFetch Ò»ÆðʹÓã»·ñÔò£¬¿ò¼Ü½«×Ô¶¯·ÖÅä±ØÒªµÄ´æ´¢Á¿¡£
Èç¹ûÄúÔ¸ÒâµÄ»°£¬¿ÉÒÔʹÓôóÁ¿ÐÐÌáÈ¡¸Ä½øÐÔÄÜ¡£ÔÚ´ò¿ª¼Ç¼¼¯¶ÔÏóÇ°£¬¿ÉÒÔÓà SetRowsetSize ³ÉÔ±º¯Êý¶¨ÒåÐм¯µÄ´óС¡£Ðм¯µÄ´óСָ¶¨ÁËÒ»´ÎÌáÈ¡Ó¦¼ìË÷¶àÉÙÌõ¼Ç¼¡£Ö´ÐдóÁ¿ÐÐÌáȡʱ£¬Ä¬ÈÏÐм¯´óСΪ 25¡£Çë×¢Òâ¡£Èç¹û²»Ö´ÐдóÁ¿ÐÐÌáÈ¡£¬Ðм¯µÄ´óС±£³Ö¹Ì¶¨Öµ 1¡£
ÔÚ½«Ðм¯´óС³õʼ»¯ºó£¬Ó¦µ÷Óà Open ³ÉÔ±º¯Êý¡£ÔÚ´Ë´¦Äú±ØÐëÖ¸¶¨ dwOptions ²ÎÊýµÄ CRecordset::useMultiRowFetch Ñ¡ÏÒÔÖ´ÐдóÁ¿ÐÐÌáÈ¡¡£ÁíÍ⣬»¹¿ÉÒÔÉèÖà CRecordset::userAllocMultiRowBuffers Ñ¡Ïî¡£´ó²¿·Ö¼Ç¼×ֶν»»»»úÖÆÔÚÌáÈ¡ÆÚ¼ä¾ùÓÃÊý×éÀ´´æ´¢¼ìË÷µ½µÄ¶àÐÐÊý¾Ý¡£ÕâЩ´æ´¢»º³åÇø¿ÉÓÉ¿ò¼Ü×Ô¶¯·ÖÅ䣬»òÕßÄúÒ²¿ÉÒÔÊÖ¹¤·ÖÅäËüÃÇ¡£Ö¸¶¨ CRecordset::userAllocMultiRowBuffers Ñ¡Ïî¾ÍÒâζ×ÅÒªÓÉÄú½øÐзÖÅä¡£
ÓÅ»¯ DAO Êý¾Ý¿âºÍ¼Ç¼¼¯¶ÔÏó
Èç¹ûʹÓà CDaoDatabase ¶ÔÏó£¬ÄúӦʹÓÃÒ»¸ö×Ö·û´®±í´ïʽ£¬¸Ã±í´ïʽÊÇÏÖÓÐ Microsoft Jet (.MDB) Êý¾Ý¿âÎļþµÄÃû³Æ¡£Èç¹ûÎļþÃûÓÐÀ©Õ¹Ãû£¬ÔòÒªÇó´øÆäÀ©Õ¹Ãû¡£Èç¹ûÄúµÄÍøÂçÖ§³ÖͳһÃüÃûÔ¼¶¨ (UNC)£¬Ôò»¹¿ÉÒÔÖ¸¶¨ÍøÂç·¾¶£¬Èç¡°\\\\MYSERVER\\MYSHARE\\MYDIR\\MYDB.MDB¡±¡££¨Ë«·´Ð±ÏßÊÇ×Ö·û´®ÎÄ×ÖÖÐËùÒªÇóµÄ£¬ÒòΪ¡°\¡±ÊÇ C++ µÄתÒå·û¡££© µ±ÒÔÕâÖÖ·½Ê½Ê¹ÓÃÊý¾Ý¿âʱ£¬ÓÐһЩÐèҪעÒâµÄÊÂÏî¡£
Èç¹ûij¸öÊý¾Ý¿âÒÑÓÉÁíÒ»¸öÓû§ÒÔ¶ÀÕ¼·ÃÎÊÐÎʽ´ò¿ª£¬MFC ¾Í»áÅ׳öÒ»¸öÒì³£´íÎó¡£Ê¹ÓøÃÒì³£´íÎó¿ÉÒÔÈÃÄúµÄÓû§ÖªµÀ¸ÃÊý¾Ý¿âÊDz»¿É·ÃÎʵġ£
Èç¹ûÄúÓÿÕ×Ö·û´® ("") ´ò¿ªÊý¾Ý¿â£¬²¢ÕýÔÚÁ¬½Óµ½ ODBC Êý¾ÝÔ´£¬¾Í»áÏÔʾһ¸ö¶Ô»°¿ò£¬¿òÖÐÁгöËùÓÐÒÑ×¢²áµÄ ODBC Êý¾ÝÔ´Ãû³Æ£¬ÒÔ±ãÓû§Ñ¡ÔñÊý¾Ý¿â¡£Ó¦±ÜÃâÓë ODBC Êý¾ÝÔ´Ö±½ÓÁ¬½Ó£»¶øÊÇʹÓÃÁ´½ÓµÄ±í¡£
CDaoDatabase ¶ÔÏó¿ÉÒÔÒÔ¶ÀÕ¼·ÃÎʵķ½Ê½´ò¿ª¡£Ä¬ÈÏÇé¿öÏ£¬ËüÊÇÒÔ¹²Ïí·ÃÎʵķ½Ê½´ò¿ªµÄ¡£¿ÉÒÔ½«Ëü×÷Ϊֻ¶ÁÊý¾ÝÔ´´ò¿ª£¬Ò²¿ÉÒÔÒÔ¶Á/д·ÃÎÊ·½Ê½´ò¿ª¡£ËùÓÐÓÉ CDaoDatabase ¶ÔÏóÅÉÉúµÄ¼Ç¼¼¯¶¼¼Ì³Ð¸ÃÊý¾Ý¿â¶ÔÏóµÄ¶ÁÈ¡ÄÜÁ¦¡£
Óë CRecordset ¶ÔÏóÒ»Ñù£¬CDaoRecordset ÓжàÖÖÀàÐÍ¡£Èç¹ûÑ¡Ôñ dbOpenDynaset£¬Äú¾ÍµÃµ½¿ÉÒÔË«Ïò¹ö¶¯µÄ¶¯Ì¬¼¯ÀàÐ͵ļǼ¼¯¡£ÕâÊÇĬÈÏÑ¡Ïî¡£Èç¹ûÑ¡Ôñ dbOpenSnapshot£¬ÄúµÃµ½µÄ¾Í½«ÊÇ¿ÉÒÔË«Ïò¹ö¶¯µÄ¿ìÕÕÀàÐ͵ļǼ¼¯¡£×îºó£¬Ê¹Óà dbOpenTable ¿ÉÒÔ´ò¿ªÄÜË«Ïò¹ö¶¯µÄ±íÀàÐ͵ļǼ¼¯¡£ÎÞ·¨Óà MFC ODBC Êý¾Ý¿âÀà´ò¿ª»ùÓÚ±íµÄ¼Ç¼¼¯¡£
CDaoRecordset ¶ÔÏóËù¾ßÓеÄÑ¡ÏîÓë CRecordset ¶ÔÏóµÄÑ¡ÏîÀàËÆ¡£
dbAppendOnly ÄúÖ»¿É×·¼ÓмǼ£¨Ö»ÏÞ¶¯Ì¬¼¯ÀàÐ͵ļǼ¼¯£©¡£¸ÃÑ¡ÏîµÄ×ÖÃæÒâ˼ÊǼǼֻ¿ÉÒÔ±»×·¼Ó¡£MFC ODBC Êý¾Ý¿âÀàÓÐÖ»×·¼ÓÑ¡Ï¸ÃÑ¡ÏîÔÊÐí¶Ô¼Ç¼½øÐмìË÷ºÍ×·¼Ó¡£
dbForwardOnly ¼Ç¼¼¯ÊÇÖ»ÏòÇ°¹ö¶¯µÄ¿ìÕÕ¡£
dbSeeChanges Èç¹ûÁíÒ»¸öÓû§Òª¸ü¸ÄÄúÕýÔڱ༵ÄÊý¾Ý£¬¾Í»áÉú³ÉÒ»¸öÒâÍâ´íÎó¡£
dbDenyWrite ÆäËûÓû§ÎÞ·¨Ð޸ĻòÌí¼Ó¼Ç¼¡£
dbDenyRead ÆäËûÓû§ÎÞ·¨²é¿´¼Ç¼£¨Ö»ÏÞ±íÀàÐͼǼ¼¯£©¡£
dbReadOnly ÄúÖ»¿É²é¿´¼Ç¼£»¶øÆäËûÓû§¿ÉÐÞ¸ÄËüÃÇ¡£
dbInconsistent ÔÊÐí²»Ò»ÖµĸüУ¨Ö»ÏÞ¶¯Ì¬¼¯ÀàÐͼǼ¼¯£©¡£
dbConsistent Ö»ÔÊÐíÒ»ÖµĸüУ¨Ö»ÏÞ¶¯Ì¬¼¯ÀàÐͼǼ¼¯£©¡£±¸×¢ ³£Á¿ dbConsistent ºÍ dbInconsistent ÊÇ»¥³âµÄ¡£ÔÚ¸ø¶¨µÄ Open ʵÀýÖÐÖ»¿ÉʹÓÃÁ½ÕßÖеÄijһ¸ö£¬¶ø²»ÄÜͬʱʹÓá£
ÓÅ»¯»ùÓÚ ODBC µÄÊý¾Ý¿â½»»¥
ÏÂÃæµÄ½¨ÒéÊÊÓÃÓÚÈκÎÉæ¼° ODBC µÄ½»»¥¡£Õâ²»½öÊÊÓÃÓÚ ODBC Êý¾Ý¿âÀ࣬¶øÇÒ¶ÔÄÇЩÓë»ùÓÚ·þÎñÆ÷µÄÊý¾ÝÒ»ÆðʹÓÃµÄ DAO Êý¾Ý¿âÀࣨDAO ʹÓà ODBC ÓëÊý¾ÝÔ´½øÐÐͨÐÅ£©Ò²ÊÊÓá£ÕâЩ½¨ÒéÖÐÓкܶ඼ÊÇÀ´×ÔÓÚ Colleen Lambert µÄÎÄÕ¡°ODBC£ºArchitecture£¬Performance£¬and Tuning¡±£¨Î»ÓÚ Microsoft Developer Network ¹âÅÌ£©¡£
ͨ¹ý²éѯÇý¶¯³ÌÐòÒ»ÖÂÐÔ¼¶±ð¶ø¾¡¿ÉÄܶàµØÀûÓÃÇý¶¯³ÌÐòµÄÄÜÁ¦¡£Èç¹û²»ÐèÒª½«Ó¦ÓóÌÐòÒÆÖ²µ½ÁíÒ»¸öƽ̨£¬¾Í¿ÉÒÔͨ¹ý×ÅÖعØעij¸öÌض¨Çý¶¯³ÌÐòµÄÄÜÁ¦£¬Ê¹ÄúÓ¦ÓóÌÐòµÄÐÔÄÜ´ïµ½×î¼Ñ״̬¡£
±ÜÃâµ÷ÓÃÊý¾ÝԴĿ¼Àý³Ì¡£ÕâЩÀý³Ì¿ÉÄÜ»áºÜºÄʱ¡£ÊÔ×ŵ÷ÓÃÀý³ÌÒ»´Î£¬²¢½«ÐÅÏ¢ÔÚ±¾µØ¸ßËÙ»º´æ¡£
ÀμǿÉÉìËõÐÔ£¬²¢Êʵ±µØÔÚ±¾µØºÍÔ¶³Ì´æ·ÅÊý¾Ý¡£Éè·¨±ÜÃâÔÚ¶þ½øλ×éºÏÂë¿òÖÐÌîÈëÀ´×ÔÔ¶³ÌÊý¾ÝÔ´µÄÊý¾Ý¡£
½« SQLExtendedFetch ÓÃÓÚ¹ö¶¯¡£Èç¹ûÄúµÄÇý¶¯³ÌÐòÖ§³ÖËü£¬ÕâÊÇ¶Ô ODBC Êý¾ÝÔ´½øÐÐÀ´»Ø¹ö¶¯µÄ×î¿ì·½·¨¡£
ÒÑ×¼±¸ºÃµÄ SQL Óï¾äÔËÐеøü¿ì¡£»¨·ÑһЩʱ¼ä×¼±¸ SQL µ÷Óã¬ÒÔ±ãËüÃǸ½¼Óµ½ HSTMT ÉÏ¡£Ö»Óиþä±úÊͷźó£¬ËüÃDzŻᱻÊÍ·Å¡£
ʹÓà SQLBindCol ¶ø²»ÊÇ SQLGetData¡£SQLBindCol ¸ºÔðÁеĴ洢ºÍÊý¾ÝÀàÐÍ£¬ÕâÑùÄú¾Í²»±ØΪ½á¹û¼¯¶øÖØлñµÃËü¡£
½« SQLTypeInfo ÔÚ±¾µØ¸ßËÙ»º´æ¡£Ä³Ð©Êý¾ÝÔ´½«¸Ãµ÷ÓÃ×÷Ϊ´æ´¢¹ý³Ì½øÐд¦Àí£¬ÕâÖ´ÐÐÆðÀ´¿ÉÄÜ»áºÜºÄ·Ñ³É±¾¡£
¾¡Á¿ÉÙʹÓÃÁ¬½Ó£¬²¢±ÜÃâ·´¸´µØ¶Ï¿ªÁ¬½ÓºÍÖØÐÂÁ¬½Ó¡£Çë¼Çס£¬³ý ODBC Çý¶¯³ÌÐò½øÐеĵ÷ÓÃÍ⣬ËüµÄ¹ÜÀíÆ÷Ò²½øÐе÷ÓÃÒÔ×¼±¸Á¬½Ó¡£ËùÓÐÕâÖÖ¿ªÏú¼ÓÆðÀ´¾Í¿ÉÄÜ´ó·ù¶È½µµÍÓ¦ÓóÌÐòµÄËٶȡ£
½«¿éÌáÈ¡ÓÃÓڶ༶Çý¶¯³ÌÐò¡£¶à¼¶Çý¶¯³ÌÐò¾³£½«ÍøÂçÐÔÄܵ±×÷×Ô¼º¹¤×÷µÄÒ»²¿·ÖʹÓ㬲¢ÇÒ£¬ÒÀÀµÓÚ SQLFetch ¶ø²»ÊÇ SQLExtendedFetch »áʹÄúµÄÓ¦ÓóÌÐòÔâÊÜÍøÂç²Ù×÷ÆæÌØÐÐΪµÄÓ°Ïì¡£
ͨ¹ýÈ«ÃæÁ˽âÄúµÄ SQL À´ÓÅ»¯²éѯ¡£Õâ¿ÉÄÜ¿´ËÆÏÔ¶øÒ×¼û£¬µ«Ðí¶à³ÌÐòԱʵ¼ÊÉÏÖ»Á˽âÓÐÏÞÊýÁ¿µÄ SQL ÃüÁî¡£¶ø¶Ô SQL Óï¾äµÄ½øÒ»²½Ñ§Ï°Ó뾫ͨ£¬¿ÉÄÜ»áʹµÃÓ¦ÓóÌÐòÓпìÓë¸ü¿ìÖ®·Ö¡£
ʹÓøßÐÔÄÜµÄ DBMS¡£ÎÒÃÇÔÚ±¾°×ƤÊéµÄ¿ªÍ·¾Í̸µ½ÁËÕâ¸öÎÊÌ⣬ºÃµÄÊý¾ÝÔ´ÊÇÓ¦ÓóÌÐòµÄÄÜÁ¦Óë²Ù×÷µÄ»ù´¡¡£ÔÚÄúµÄ¿Í»§¶Ë¸ºµ£µÃÆðµÄÇ°ÌáÏ£¬Ê¹ÓÃ×îºÃµÄÊý¾ÝÔ´¡£
ÏÂÃæµÄ½¨ÒéÊÇרÓÃÓÚ DAO Êý¾Ý¿âÀàµÄ¡£¸ÃÁбíÖдøÐǺŵÄÏîÖ÷ÒªÊÇÖ¸Óë ODBC£¨»ùÓÚ·þÎñÆ÷£©Êý¾ÝÔ´µÄ½»»¥¡£
¾¡¿ÉÄÜʹÓÃÁ´½ÓµÄ±í¶ø²»ÊÇÖ±½Ó´ò¿ªµÄ±í¡£Çë²Î¼û DAO¡°°ïÖú¡±ÖеÄÎÄÕ¡°DAO External£ºWorking with External Data Sources and the topic Accessing External Databases with DAO¡±¡£ÔÚ´ËÁбíµÄËùÓн¨ÒéÖУ¬ÕâÏÒé¶ÔÐÔÄܵÄÓ°Ïì×îΪÏÔÖø¡£*
Èç¹û²»¸üÐÂÊý¾Ý£¬¾Í²»ÒªÊ¹Óö¯Ì¬¼¯ÀàÐ͵ļǼ¼¯¡£Èç¹ûÖ»ÏòÇ°¹ö¶¯£¬¾ÍʹÓÃÏòÇ°¹ö¶¯µÄ¿ìÕÕÀàÐ͵ļǼ¼¯¡£²»±ØÒªµÄ»°²»Òª´ÓÍ·ÖÁβ¹ö¶¯¼Ç¼£¬»¹Òª±ÜÃâÌøµ½´óÐͱíµÄ×îºóÒ»Ìõ¼Ç¼¡£
Ö»¼ìË÷Óë²é¿´ÐèÒªµÄÊý¾Ý¡£ÓÃÊÜÏÞ²éѯÀ´ÏÞÖÆÒª¼ìË÷µÄ¼Ç¼ÊýÁ¿£¬²¢ÇÒֻѡÔñÄúÐèÒªµÄÁС£ÕâÑù»áʹµÃÒªÇóͨ¹ýÍøÂç´«ÊäµÄÊý¾Ý¸üÉÙ¡£
ʹÓøßËÙ»º³å¡£ÔÚÀà CDaoRecordset ÖУ¬MFC Ö§³Ö¶ÔÖ¸¶¨ÊýÁ¿µÄ¼Ç¼½øÐиßËÙ»º´æ¡£Ò»¿ªÊ¼ÔÚ½«Êý¾Ý¼ìË÷µ½¸ßËÙ»º´æÖÐʱ£¬ÕâÑù×ö»¨·ÑµÄʱ¼ä»á½Ï³¤£»µ«ÔÚ¸ßËÙ»º´æÖÐÒƶ¯²¢¹ö¶¯£¨ÒѼìË÷µÄ£©¼Ç¼Ҫ±È¹ö¶¯¼ìË÷ÿÌõ¼Ç¼¿ìһЩ¡£*
¹Ø±Õ MFC CDaoRecordset ¶ÔÏóÖеÄË«»º³åÑ¡Ïî¡£ÕâÊǸĽøÐÔÄܵij£¹æ·½·¨£¬Ò²ÊÊÓÃÓÚʹÓÃÍⲿÊý¾ÝÔ´µÄÇé¿ö¡£
¶ÔÓÚÁ¿±È½Ï´óµÄ²Ù×÷£¬Èç´óÁ¿Ìí¼Ó¼Ç¼£¬ÇëʹÓà SQL Ö±½Ó´«µÝ²éѯ¡£µ±Ê¹Óà SQL Ö±½Ó´«µÝ²éѯʱ£¬Ö»ÒªÄúʼÖÕͨ¹ýͬһÁ¬½ÓÖ´ÐÐ SQL Ö±½Ó´«µÝ²éѯ£¬¾ÍÖ»ÐèÒ»´ÎÐÔµØÉèÖÃÁ¬½ÓÐÅÏ¢¼´¿É¡£*
±ÜÃâʹÓûᵼÖ±¾µØ´¦ÀíµÄ²éѯ¡£* ²»ÒªÊ¹Óú¬ÓÐÔ¶³ÌÁвÎÊýµÄÓû§¶¨Ò庯Êý¡£Ö»ÔÚË÷ÒýÁÐÉÏʹÓÃÒìÀàÁª½Ó£¨ÔÚÁ½¸öÊý¾Ý¿âÖеıíÉÏÁª½Ó£©£¬²¢ÇÒ£¬Èç¹ûÄúÕâÑù×öµÄ»°£¬Çë×¢Ò⵽ijЩ´¦ÀíÊÇÔÚ±¾µØÍê³ÉµÄ¡£µ±·ÃÎÊÍⲿÊý¾Ýʱ£¬Ö»ÓÐÔÚÍⲿÊý¾Ý¿âÎÞ·¨Ö´ÐвÙ×÷ʱ£¬Microsoft Jet Êý¾Ý¿âÒýÇæ²Å»áÔÚ±¾µØ´¦ÀíÊý¾Ý¡£ÔÚ±¾µØÖ´ÐеIJéѯ²Ù×÷ÓУº
²éѯ¶¥²¿º¬ÓÐ DISTINCT ν´ÊµÄ WHERE ×Ó¾äÏÞÖÆ¡£Í¨³££¬Äú¿ÉÒÔÖØа²ÅŲéѯ£¬ÒÔ¼ÆËãºÏ¼Æ»òÔÚËùÓÐÆäËü²Ù×÷ºóµÄ DISTINCT ²éѯÊýÁ¿¡£
º¬ÓÐÎÞ·¨Ô¶³Ì´¦ÀíµÄ²Ù×÷µÄ WHERE ×Ӿ䣬ÈçÉæ¼°µ½Ô¶³ÌÁеÄÓû§¶¨Ò庯Êý¡££¨Çë×¢Ò⣬ÕâÖÖÇé¿öÏ£¬Ö»ÓÐÄÇЩÎÞ·¨Ô¶³Ì´¦ÀíµÄ WHERE ×Ӿ䲿·Ö½«ÔÚ±¾µØ´¦Àí¡££©
À´×Ô²»Í¬Êý¾ÝÔ´µÄ±íÖ®¼äµÄÁª½Ó¡£½ö¿¿À´×Ô²»Í¬Êý¾ÝÔ´µÄ±íÖ®¼ä´æÔÚÁª½ÓÕâÒ»¸öÌõ¼þ£¬²¢²»Äܶ϶¨ËùÓд¦Àí¶¼»áÔÚ±¾µØ·¢Éú¡£Èç¹û½«ÏÞÖÆ·¢Ë͸ø·þÎñÆ÷£¬ÔòÖ»ÓÐÏà¹ØµÄÐлáÔÚ±¾µØ´¦Àí¡£
Ôھۺϻò DISTINCT ν´ÊÉϵÄÁª½Ó¡£ÎÞÂÛÈçºÎ£¬ÕýÈ·µØÁª½Ó¶¼ÊÇÒ»ÃÅÒÕÊõ£¬Ìí¼Ó¾ÛºÏº¯Êý£¨Èç AVG¡¢MAX ºÍ MIN£©»òº¬ÓÐ DISTINCT µÄν´ÊÖ»»á¼õÂý²éѯ¡£
º¬Óв»Îª ODBC Çý¶¯³ÌÐòËùÖ§³ÖµÄÓï·¨µÄÍâÁª½Ó¡£×ÀÃæÊý¾Ý¿âÇý¶¯³ÌÐò²»½öÖ§³Ö×óÏòÍâÁª½ÓºÍÓÒÏòÍâÁª½Ó£¬»¹Ö§³ÖÄÚÁª½Ó ×óÏòÍâÁª½ÓÖеÄÓÒ±íºÍÓÒÏòÍâÁª½ÓÖеÄ×ó±í¶¼¿ÉÓÃÓÚÄÚÁª½ÓÖС£ÍêÈ«µÄºÍǶÌ×µÄÍâÁª½Ó¶¼²»ÊÜÖ§³Ö¡£
½ÓÏÂÀ´µÄÈýÏîרÓÃÓÚÄúÏëÒª´ÓÔ¶³ÌÊý¾ÝÔ´·ÃÎʵÄÊý¾Ý¡£
º¬ÓÐÎÞ·¨Ô¶³Ì´¦ÀíµÄ²Ù×÷µÄ DISTINCT ν´Ê¡£
ORDER BY ²ÎÊý£¨Èç¹ûÔ¶³ÌÊý¾ÝÔ´²»Ö§³ÖËüÃÇ£©¡£
º¬ÓÐÎÞ·¨Ô¶³Ì´¦ÀíµÄ²Ù×÷µÄ ORDER BY »ò GROUP BY ²ÎÊý¡£
¡°²»¿ÉÔ¶³Ì´¦ÀíµÄ¡±±í´ïʽÊÇÎÞ·¨ÓÉÄúµÄ·þÎñÆ÷ÇóÖµµÄ¡£²»¿ÉÔ¶³Ì´¦ÀíµÄÊä³ö±í´ïʽ£¨SELECT ×Ó¾äÖеÄÄÇЩ±í´ïʽ£©²»Ç¿ÖƶÔÄúµÄ²éѯ½øÐб¾µØÇóÖµ£¬³ý·ÇÕâЩ±í´ïʽ³öÏÖÔںϼƲéѯ¡¢DISTINCT ²éѯ»ò UNION ²éѯÖС£ÆäËü×Ӿ䣨Èç WHERE¡¢ORDER BY¡¢GROUP BY¡¢HAVING µÈ£©ÖеIJ»¿ÉÔ¶³Ì´¦ÀíµÄ±í´ïʽÖÁÉÙÇ¿ÖÆÄúµÄ²¿·Ö²éѯÔÚ±¾µØÇóÖµ¡£
²éѯ¶¥²¿º¬ÓÐ DISTINCT Ñ¡ÏîµÄ GROUP BY ²ÎÊý¡£Ê¹Óà SELECT DISTINCTROW£¬ºó¸ú GROUP BY ×Ӿ䡣
ÏÂÃæµÄ¹¦ÄÜÔÚËùÓÐÒÑÖªµÄ ODBC ¿É·ÃÎʵķþÎñÆ÷É϶¼ÊDz»±»Ö§³ÖµÄ - ͨ³£ÊÇһЩÕâÑùµÄ²Ù×÷£ºËüÃÇÊÇ Microsoft Jet ÌØÓÐµÄ¶Ô SQL µÄÀ©Õ¹£¬È磺
¶à¼¶±ð GROUP BY ²ÎÊý£¬ÈçÔÚº¬Óжà¸ö·Ö×鼶±ðµÄ±¨¸æÖÐʹÓõIJÎÊý¡£
TOP »ò TOP PERCENT ν´Ê¡£
Óжà¸ö¾ÛºÏµÄ½»²æ±í²éѯ»òº¬ÓÐÓë GROUP BY ×Ó¾äÆ¥ÅäµÄ ORDER BY ×Ó¾äµÄ½»²æ±í²éѯ¡£¼òµ¥µÄ½»²æ±í²éѯ¿ÉÒÔ·¢Ë͵½·þÎñÆ÷¡£
ÆäËüÓÃÓÚÓÅ»¯Ó¦ÓóÌÐòµÄ×ÊÔ´
Visual C++ Ëæ´øµÄÎĵµÓ¦ÊǹØÓÚ MFC ʵÏÖ DAO µÄµÚÒ»¸öÐÅÏ¢À´Ô´¡£²»½öÓ¦¸Ã²éÔÄ MFC DAO ʾÀýºÍ MFC ¼¼Êõ˵Ã÷£¬»¹Ó¦²éÔÄ Class Library Reference ºÍ Programming with MFC¡£
ÓÐ¹Ø DAO ¹¤×÷·½Ê½µÄÆäËüÐÅÏ¢£¬Çë²éÔÄ Microsoft Jet Database Engine Programmer's Guide£¨Microsoft Press ³ö°æ£©¡£
ÁíÍ⻹ÓÐÁ½ÆªÍƼöÎÄÕ£¬¾ùλÓÚ Microsoft Developer Network ¹âÅÌÉÏ£¬ËüÃÇÊÇ£º
¡°Jet Database Engine ODBC Connectivity¡±£¬×÷ÕߣºBlack¡¢Neil ºÍ Stephen Hecht¡£
ÕâƪÎÄÕÂÏêϸ½²ÊöÁË Microsoft Jet ÈçºÎʹÓà ODBC ¼ìË÷·þÎñÆ÷Êý¾Ý¡£¶ÔÓÚËùÓÐÓà DAO ±àдÖØÒª·þÎñÆ÷Ó¦ÓóÌÐòµÄÈË£¬Õⶼ²»Ê§ÎªÒ»Æª±Ø¶ÁÎÄÕ¡£
¡°ODBC£ºArchitecture£¬Performance£¬and Tuning¡±£¬×÷ÕߣºLambert¡¢Colleen¡£
±¾°×ƤÊéÌṩ¶Ô ODBC ¹¤×÷·½Ê½µÄÁ¼ºÃ¸ÅÊö£¬²¢ÒÔÏÖʵ¡¢ÓÐÓõķ½Ê½½²ÊöÁËÐÔÄÜÎÊÌâ¡£
½áÂÛ
MFC µÄ»ù±¾¸ÅÄ¼´Îª¸ü¸´Ôӵļ¼ÊõÌṩ¸ß¼¶±ð³éÏó£©ÔÚÕâЩÊý¾Ý¿âÀàÖÐÊÇ¿ÉÒÔʵÏֵġ£Äú¿ÉÒÔÑ¡Ôñ ODBC »òÊÇ DAO£¬ÒÔ»ñµÃ¿Éʹ¿Í»§¶Ë³É¹¦µÄ×î¼Ñ·¾¶¡£
ÎÒÃÇ»¨ÁËÏ൱¶àµÄʱ¼ä¼ì²é¸Ä½øÐÔÄܵķ½·¨£¬¿´µ½ÁËһЩÓëÔÚÐí¶àÊý¾ÝÔ´ÉÏÀàµÄÖ´Ðз½Ê½Óйصķ½·¨£¬²¢ÏòÄúÌá³öÁËÐí¶àÒª¿¼ÂǵÄÎÊÌâ¡£²»¹ÜÄú×öʲô£¬ÔÚ¾ö¶¨ÒÔÇ°¶¼Çë±£³ÖÔÐÍ¡£ÎÒÃÇÏ£Íû½ñÌìµÄ»áÒéÄÜ°ïÖúÄúËõСѡÔñ·¶Î§£¬²¢Ê¹ÄúµÄ¾ö¶¨¸üÈÝÒ×ʵÏÖ¡£
hnhyang ÓÚ 2007-07-24 00:18:33·¢±í:
:0D1 :0(1
csbinghu ÓÚ 2007-05-18 21:04:59·¢±í:
:ha3nd
zz123 ÓÚ 2005-08-20 00:28:17·¢±í:
ºÃ³¤£¬Ö§³Ö