Lm th? no ? nn b? my c s? d? li?u truy c?p Microsoft qua ADO

D?ch tiu ? D?ch tiu ?
ID c?a bi: 230501
Bung t?t c? | Thu g?n t?t c?

? Trang ny

TM T?T

M?c d ADO ?c i?m k? thu?t khng cung c?p cc ?i t?ng ? nn b? my c s? d? li?u Microsoft Access, kh? nng ny c th? ?t ?c b?ng cch s? d?ng ph?n m? r?ng ADO: Microsoft ph?n l?c OLE DB Provider v nhn r?ng cc ?i t?ng (JRO). Kh? nng ny ?c th?c hi?n l?n ?u tin trong my bay ph?n l?c OLE DB Provider Phin b?n 4.0 (Msjetoledb40.dll) v JRO Phin b?n 2,1 (Msjro.dll). Nh?ng t?p tin DLL c s?n sau khi ci ?t chuyn bi?t c?a MDAC 2.1. B?n c th? t?i phin b?n m?i nh?t c?a MDAC t? cc web site sau y:
Ph? qut trang truy nh?p d? li?u Web

THNG TIN THM

? nh? g?n m?t b? my c s? d? li?u truy c?p b?ng cch s? d?ng ADO, MDAC 2,1 tr? ln ph?i ?c ci ?t chuyn bi?t ng trn my tnh. Sau y l cc b?c chnh ? nn b? my c s? d? li?u Microsoft Access b?ng cch s? d?ng Visual Basic, Visual c + +:

Visual Basic: Nn m?t b? my c s? d? li?u truy c?p thng qua ADO

  1. Trong IDE Visual Basic, trn cc d? n menu, nh?p vo ti li?u tham kh?o.
  2. Thm my bay ph?n l?c Microsoft v nhn r?ng cc ?i t?ng X.X th vi?n, ni (X.X l l?n hn ho?c b?ng v?i 2,1).
  3. Thm d?ng sau m? Visual Basic, thay th? ?ng d liu ngun v i?m ?n b? my c s? d? li?u i n?u c?n thi?t:
    Dim jro As jro.JetEngine
    Set jro = New jro.JetEngine
    jro.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\nwind2.mdb;Jet OLEDB:Database Password=test", _ 
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\abbc2.mdb;Jet OLEDB:Engine Type=4;Jet OLEDB:Database Password=test"
    					
Lu ?: Trong ?o 3,60, phng php RepairDatabase khng c?n c s?n. M? ? trn cho th?y vi?c s? d?ng cc phng php CompactDatabase. Phng php ny s? thay th? cc phng php o 3,5 RepairDatabase.

Visual c + +: Nn m?t b? my c s? d? li?u truy c?p thng qua ADO

  1. Bn c?nh #import, Msado15.dll (MDAC2.1), thm cc cu #import sau y ? t?o ra cc wrapper l?p cho JRO cho cc l?p h?c .cpp (ngoi ra, b?n c th? t?o cc wrapper l?p h?c hi?u qu? hn b?ng cch s? d?ng cc thu?c tnh no_implementation v implementation_only c?a bo co pre-processor #import):
    #import "C:\PROGRAM FILES\COMMON FILES\System\ado\MSJRO.DLL" no_namespace 
    					
  2. Thm nh sau (cch xc ?nh ?ng d?n b? my c s? d liu ngun v i?m ?n c?a ring b?n) ? cc t?p tin .cpp ni b?n mu?n ? nn c s? d? li?u:
    ...
    try
    {
       IJetEnginePtr jet(__uuidof(JetEngine));
      jet->CompactDatabase( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\nwind2.mdb;Jet OLEDB:Database Password=test", 
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\abbc.mdb;" \ 
    "Jet OLEDB:Engine Type=4;Jet OLEDB:Database Password=test");
    }
    catch(_com_error &e) 
    {       
       ::MessageBox(NULL, (LPCTSTR)e.Description( ), "", MB_OK) ;    
    }
    					
Lu ?: Ki?u my bay ph?n l?c OLEDB:Engine = 4 l ch? cho cc my bay ph?n l?c 3.x d?ng th?c t?p MDB. N?u gi tr? ny l tri, b? my c s? d? li?u t? ?ng ?c nng c?p ln phin b?n 4,0 (my bay ph?n l?c OLEDB:Engine Type = 5). Xem b?ng d?i y cho cc gi tr? thch h?p cho my bay ph?n l?c OLEDB:Engine lo?i:
Thu g?n b?ng nyBung r?ng b?ng ny
My bay ph?n l?c OLEDB:Engine lo?iMy bay ph?n l?c x.x ?nh d?ng MDB Files
1JET10
2JET11
3JET2X
4JET3X
5JET4X

THAM KH?O

? bi?t thm chi ti?t, xin vui l?ng xem d?i y bi vi?t trong c s? ki?n th?c Microsoft:
230496 Nn b? my c s? d? li?u Microsoft Access qua OLE DB

Thu?c tnh

ID c?a bi: 230501 - L?n xem xt sau cng: 16 Thang Nm 2012 - Xem xt l?i: 3.0
T? kha:
kbhowto kbjet kbprovider kbmt KB230501 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:230501
Khc t Ni dung trong C s Kin thc Khng con c h tr
Bi vi?t ny ni v? cc s?n ph?m m Microsoft khng c?n h? tr? n?a. Do , bi vi?t ny ?c cung c?p "nguyn b?n" v s? khng ?c c?p nh?t.

Cung cp Phan hi

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com