Lm th? no ? t?o ra m?t.MDB File cho c s? d? li?u Microsoft Access

D?ch tiu ? D?ch tiu ?
ID c?a bi: 118609 - Xem s?n ph?m m bi ny p d?ng vo.
Bung t?t c? | Thu g?n t?t c?


Lu ?: thng tin v? lm th? no ? t?o ra.MDB file l?p tr?nh b?ng cch s? d?ng Visual C++ Phin b?n 4.x ho?c sau ny, xin vui l?ng xem cc bi vi?t sau y trong cc C s? ki?n th?c Microsoft:
126606Thng tin: Truy c?p vo CREATE_DB, REPAIR_DB v COMPACT_DB
M?t t?p tin .mdb lun lun l c?n thi?t ? c?u h?nh m?t ngu?n d? li?u Microsoft Access ho?c b?ng cch s? d?ng cc qu?n tr? vin k?t n?i c s? d? li?u m? (ODBC) ho?c b?ng c?u h?nh ngu?n d? li?u l?p tr?nh. M?t t?p tin .mdb c th? khng t?o b?ng cch s? d?ng cc l?p h?c c s? d? li?u MFC ho?c ?ng d?ng ODBC giao di?n l?p tr?nh (API).

B?n c th? s? d?ng m?t trong nh?ng phng php sau y ? c m?t ?ng d?ng c?u h?nh m?t ngu?n d? li?u trn my tnh c?a b?n:

  • Tu v ci ?t cc t?p tin .mdb cng v?i cc ?ng d?ng.
  • Lm cho cc t?p tin .mdb vo m?t ng?i dng xc ?nh ngu?n l?c. Sau , sao chp .mdb t?p tin t?i th?i gian ch?y.
Bi vi?t ny th?o lu?n v? phng php th? hai, lm cho cc t?p tin .mdb vo m?t ng?i s? d?ng- ti nguyn ?c xc ?nh.


B?n c th? s? d?ng m?t ng?i dng xc ?nh ngu?n l?c ? nh km linh tinh d? li?u ?n m?t.EXE t?p tin. N?u m?t t?p tin .mdb ?c lm thnh m?t ngu?n l?c, ti nguyn c th? ?c n?p T?i th?i gian ch?y v sau b?ng vn b?n vo m?t t?p tin .mdb. Cc b?c c?n thi?t ? lm i?u ny l nh sau:

  1. T?o m?t t?p tin .mdb ho?c b?ng cch s? d?ng Microsoft Access ho?c MSQuery.
  2. T?o t?p tin .mdb nh m?t ng?i dng xc ?nh ngu?n l?c b?ng cch thm sau y d?ng c?a b?n.RC t?p:
          mdb_file  MDB_RESOURCE filename.mdb
          mdb_file      is  a name for identifying the resource.
          MDB_RESOURCE  is  a name for identifying the type of the resource
                            and can be any user-defined type.
          filename.mdb  is  the name of the .mdb file.
  3. N?p ti nguyn v vi?t n ra vo m?t t?p tin .mdb. B?n c th? s? d?ng cc theo ch?c nng, t? b?t c? ni no trong ?ng d?ng c?a b?n, ? t?o ra cc .mdb t?p tin. (M?t ni tiu bi?u cho vi?c t?o ra cc t?p tin .mdb s? cc ghi ln cc ch?c nng CWinApp::InitInstance().)
          // Get the instance handle - required for loading the resource
          HINSTANCE hInst = AfxGetInstanceHandle();
          // Load the user-defined resource.
          HRSRC hmdbFile = ::FindResource(hInst, "mdb_file", "MDB_RESOURCE");
             HGLOBAL hRes = ::LoadResource(hInst, hmdbFile);
             DWORD dwResSize = ::SizeofResource(hInst, hmdbFile);
             if (hRes != NULL)
                UINT FAR* lpnRes = (UINT FAR*)::LockResource(hRes);
                CString szFileName = "Filename.mdb";
                   // Create the .mdb file
                   CFile f( szFileName, CFile::modeCreate | CFile::modeWrite );
                   // Write the user-defined resource to the .mdb file
                   f.WriteHuge(lpnRes, dwResSize);
                CATCH( CFileException, e )
          #ifdef _DEBUG
                 afxDump << "File could not be opened " << e->m_cause << "\n";
          #ifndef WIN32 //Unlock Resource is obsolete in the Win32 API
M?t b?t l?i c?a phng php ny l n lm tng kch th?c c?a cc file exe theo ? kch th?c c?a t?p tin .mdb. B?i v? ngay c? m?t s?n ph?m no .mdb t?p tin l 64 K trong kch th?c, exe tng t?i thi?u 64 K. M?t trong nh?ng cch ? lm gi?m kch th?c c?a exe l ? lu tr? m?t t?p tin nn .mdb ln cc exe v m? r?ng n lc ch?y th?i gian khi lu tr? ti nguyn.


? bi?t thm chi ti?t v? xc ?nh ng?i s? d?ng ti nguyn, ? c?p ?n Windows SDK Tr? gip.

? thm thng tin v? c?u h?nh ngu?n d? li?u m?t l?p tr?nh, Xin vui l?ng xem cc bi vi?t sau trong c s? ki?n th?c Microsoft:
110507Lm th? no ? c?u h?nh ngu?n d? li?u ODBC trn bay

110508Lm th? no ? t?o b?ng v?i n?n t?ng c s? d? li?u cc l?p h?c

Thu?c tnh

ID c?a bi: 118609 - L?n xem xt sau cng: 17 Thang Tam 2011 - Xem xt l?i: 2.0
p d?ng
  • Microsoft Foundation Class Library 4.2, khi ?c dng v?i:
    • Microsoft Visual C++ 1.52 Professional Edition
    • Microsoft Visual C++ 2.1
T? kha:
kbdatabase kbhowto kbprogramming kbmt KB118609 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:118609
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