ODBC vs ADO
Feem ntau, cov ntawv thov software raug sau ua hom lus tshwj xeeb (xws li Java, C, thiab lwm yam), thaum cov ntaub ntawv lees txais cov lus nug hauv qee hom lus tshwj xeeb (xws li SQL). Yog li ntawd, thaum daim ntawv thov software xav tau nkag mus rau cov ntaub ntawv hauv database, ib qho interface uas tuaj yeem txhais cov lus rau ib leeg (daim ntawv thov thiab database) yuav tsum tau. Txwv tsis pub, daim ntawv thov programmers yuav tsum kawm thiab koom nrog cov lus tshwj xeeb hauv lawv daim ntawv thov. ODBC (Qhib Database Connectivity) thiab OLE DB (Object Linking and Embedding, Database) yog ob qho kev cuam tshuam uas daws qhov teeb meem tshwj xeeb no. ODBC yog lub platform, hom lus thiab kev ua haujlwm ywj pheej interface uas tuaj yeem siv rau lub hom phiaj no. OLE DB yog tus ua tiav rau ODBC. ADO yog cov ntaub qhwv rau OLE DB.
ODBC yog dab tsi?
ODBC yog qhov sib cuam tshuam rau kev nkag mus rau kev tswj hwm database (DBMS). ODBC yog tsim los ntawm SQL Access Group nyob rau hauv 1992 ib lub sij hawm, thaum tsis muaj tus qauv nruab nrab los sib txuas lus ntawm ib tug database thiab ib daim ntawv thov. Nws tsis nyob ntawm ib hom lus programming lossis database system lossis operating system. Cov programmers tuaj yeem siv ODBC interface los sau cov ntawv thov uas tuaj yeem nug cov ntaub ntawv los ntawm txhua qhov chaw khaws ntaub ntawv, txawm hais tias ib puag ncig nws tab tom khiav lossis hom DBMS nws siv.
Vim tias tus tsav tsheb ODBC ua tus txhais lus ntawm daim ntawv thov thiab cov ntaub ntawv, ODBC muaj peev xwm ua tiav cov lus thiab kev ywj pheej ntawm lub platform. Qhov no txhais tau hais tias daim ntawv thov raug tshem tawm ntawm lub nra ntawm kev paub cov ntaub ntawv tshwj xeeb cov lus. Hloov chaw nws tsuas yog paub thiab siv ODBS syntax thiab tus tsav tsheb yuav txhais cov lus nug rau hauv cov ntaub ntawv hauv hom lus nws tuaj yeem nkag siab. Tom qab ntawd, cov txiaj ntsig tau xa rov qab rau hauv hom ntawv uas tuaj yeem nkag siab los ntawm daim ntawv thov. ODBC software API tuaj yeem siv nrog ob qho tib si kev sib raug zoo thiab tsis sib raug zoo database systems. Lwm qhov zoo dua ntawm kev muaj ODBC ua ib qho nruab nrab nruab nrab nruab nrab ntawm daim ntawv thov thiab cov ntaub ntawv yog tias txhua zaus cov ntaub ntawv hloov pauv, cov software tsis tas yuav hloov kho. Tsuas yog qhov hloov tshiab rau ODBC tus tsav tsheb yuav txaus.
ADO yog dab tsi?
ADO yog ib phau ntawm COM (Component Object Mode) cov khoom uas ua haujlwm rau kev nkag mus rau cov ntaub ntawv hauv cov ntaub ntawv. ADO tau tsim xyoo 1996 los ntawm Microsoft ua ib feem ntawm Microsoft Data Access Components (MDAC). ADO tsim cov txheej txheem nruab nrab ntawm cov ntawv sau npe hauv qee hom lus programming thiab OLE DB (cov ntaub ntawv API tsim los ntawm Microsoft thiab tus ua tiav rau ODBC). Programmers tuaj yeem siv ADO kom nkag mus rau cov ntaub ntawv yam tsis paub txog cov ntsiab lus ntawm kev siv cov ntaub ntawv. Txawm hais tias koj tsis tas yuav tsum paub SQL siv ADO, koj tuaj yeem ua tiav SQL nqe lus siv nws.
Dab tsi yog qhov txawv ntawm ODBC thiab ADO?
ODBC yog qhov qhib interface, uas tuaj yeem siv los ntawm txhua daim ntawv thov los sib txuas lus nrog txhua qhov system database, thaum ADO yog ib puag ncig OLE DB (uas yog tus ua tiav rau ODBC). Yog tias cov ntaub ntawv tsis txhawb OLE (tsis yog-OLE ib puag ncig) ces ODBC yog qhov kev xaiv zoo tshaj. Yog tias ib puag ncig tsis yog SQL, ces koj yuav tsum siv ADO (vim ODBC ua haujlwm nrog SQL nkaus xwb). Yog xav tau cov ntaub ntawv sib koom ua ke, ces ADO yuav tsum tau siv ODBC. Txawm li cas los xij, rau 16-ntsis cov ntaub ntawv nkag mus rau ODBC yog tib txoj kev xaiv (ADO tsis txhawb 16-ntsis). Thaum kawg, ADO yog qhov kev xaiv zoo tshaj plaws rau kev txuas mus rau ntau lub databases ib zaug (ODBC tuaj yeem txuas rau ib lub database nkaus xwb).