Lm th? no ? s? d?ng phng php OpenDatabase ? m? m?t kh?u b?o v? c s? d? li?u Access 2000

D?ch tiu ? D?ch tiu ?
ID c?a bi: 209953 - Xem s?n ph?m m bi ny p d?ng vo.
V?a ph?i: ?i h?i v? m c b?n, m? ha, v kh? nng tng tc k? nng.

Bi vi?t ny ch? p d?ng cho m?t c s? d? li?u Microsoft Access (.mdb).

Bung t?t c? | Thu g?n t?t c?

TM T?T

Bi vi?t ny m t? cch s? d?ng cc OpenDatabase phng php ? m? m?t c s? d? li?u Microsoft Access c m?t c s? d? li?u m?t kh?u. Lu ? r?ng i?u ny l khc nhau t? vi?c m? m?t c s? d? li?u ?c b?o v? v?i tnh nng b?o m?t c?p ng?i s? d?ng Microsoft Access.

THNG TIN THM

N?u b?n mu?n s? d?ng cc OpenDatabase phng php ? m? c s? d? li?u m?t kh?u b?o v?, ch? ?nh cc c s? d? li?u m?t kh?u nh l m?t ph?n c?a cc K?t n?i ?i s?. C php ? m? m?t c s? d? li?u v?i cc OpenDatabase phng php l nh sau:
?t db = workspace.OpenDatabase)dbname, ty ch?n, ch? ?c, k?t n?i)
LU ?: M?c d cc Tuy chon v Ch? ?c ?i s? c?a cc OpenDatabase phng php ?c di?n t? trong tr? gip nh l ?i s? ty ch?n, b?n ph?i cung c?p cho h? khi b?n s? d?ng cc K?t n?i ?i s?. N?u b?n s? d?ng m?t K?t n?i ?i s? v b?n khng cung c?p cc Tuy chon v Ch? ?c ?i s?, b?n nh?n ?c th?i gian ch?y l?i 3031:
Khng ph?i l m?t m?t kh?u h?p l?.
B?n nh?n ?c thng bo l?i ny ngay c? khi m?t kh?u m b?n ? cung c?p trong cc K?t n?i ?i s? l chnh xc. N?u b?n khng c?n ph?i s? d?ng m?t K?t n?i ?i s?, b?n c th? b? qua cc Tuy chon v Ch? ?c ?i s?.

Khi b?n s? d?ng cc OpenDatabase phng php ? m? m?t m?t kh?u b?o v? Access database, cc K?t n?i ?i s? c?a cc OpenDatabase phng php yu c php sau:
MS Access; pwd =m?t kh?u
S? d?ng cc OpenDatabase phng php ? m? c s? d? li?u m?u Northwind.mdb ( l b?o v? b?ng m?t kh?u c s? d? li?u c?a "northwind"), lm theo cc b?c sau:

LU ?: M?u m? trong bi vi?t ny s? d?ng truy c?p d? li?u c?a Microsoft Cc ?i t?ng. ?i v?i m? ny ? ch?y ng cch, b?n ph?i tham kh?o Microsoft DAO 3.6 ?i t?ng th vi?n. ? lm i?u ny, b?m Tham khao trn cc Cng cu tr?nh n trong Visual Basic Editor, v ?m b?o r?ng cc Microsoft DAO 3,6 ?i t?ng th vi?n ch?n h?p ki?m.

TH?N TR?NG: N?u b?n lm theo cc b?c trong v d? ny, b?n s?a ?i m?u c s? d? li?u Northwind.mdb. B?n c th? mu?n sao lu cc t?p tin Northwind.mdb v lm theo cc b?c trn m?t b?n sao c?a c s? d? li?u.

  1. B?t ?u Microsoft Access v m? c s? d? li?u m?u Northwind.mdb cho truy c?p ?c quy?n. ? lm i?u ny, b?m C s? d? li?u m? trn cc Tp tr?nh n, nh?p vo m?i tn vo cc M? nt ? hi?n th? cc ty ch?n, v sau nh?p vo ?c quy?n m?.
  2. Trn cc Cng cu tr?nh n, i?m ?n Bao mt, v sau nh?p vo Thi?t l?p c s? d? li?u m?t kh?u.
  3. Lo?i Northwind trong c? hai cc M?t kh?u v Ki?m ch?ng h?p.
  4. Nh?p vo Ok ? ng nh?ng Thi?t l?p c s? d? li?u m?t kh?u h?p tho?i.
  5. ng c s? d? li?u.
  6. T?o m?t c s? d? li?u m?i, tr?ng.
  7. T?o m?t m-un v g? th? t?c sau y:

    LU ?: Thay th? ?ng d?n chnh xc ? Northwind.mdb trn ?a c?ng c?a b?n trong m?u m? sau y.
    Sub OpenDB()
     Dim db As DAO.Database
     Dim ws As DAO.WorkSpace
     Dim rst As DAO.Recordset
     Set ws = DBEngine.WorkSpaces(0)
     Set db = ws.OpenDatabase _
     ("C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb", _
     False, False, "MS Access;PWD=northwind")
     Set rst = db.OpenRecordset("Customers", dbOpenDynaset)
     If rst.RecordCount > 0 Then
       rst.MoveLast
       MsgBox rst!CustomerID
     End If
     rst.Close
     db.Close
    End Sub
    					
  8. ? ki?m tra th? t?c ny, g? d?ng sau trong cc Debug c?a s?, v sau nh?n ENTER:
    OpenDB
    Lu ? r?ng m?t h?p thng i?p s? hi?n th? ID khch hng cu?i cng ghi l?i trong khch hng b?ng, ch? ra r?ng c s? d? li?u ? thnh cng m?.

THAM KH?O

? bi?t thm thng tin v? phng php OpenDatabase, b?m Tr? gip Microsoft Visual Basic trn cc Tr giup tr?nh n, lo?i phng php opendatabase trong tr? l? vn ph?ng ho?c thu?t s? tr? l?i, v sau b?m Tim kim ? xem cc ch? ?.

? bi?t thm chi ti?t v? c s? d? li?u m?t kh?u, b?m Tr? gip Microsoft Access trn cc Tr giup tr?nh n, lo?i b?o v? c s? d? li?u truy c?p microsoft (.mdb) t?p tin v?i m?t m?t kh?u ho?c m? ha trong tr? l? vn ph?ng ho?c cc Thu?t s? tr? l?i, v sau nh?p vo Tim kim ? xem cc ch? ? tr? l?i.

Thu?c tnh

ID c?a bi: 209953 - L?n xem xt sau cng: 17 Thang Chin 2011 - Xem xt l?i: 3.0
p d?ng
  • Microsoft Access 2000 Standard Edition
T? kha:
kbautomation kbpasswords kbdatabase kbopenfile kbhowto kbprogramming kbmt KB209953 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:209953

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