Solved the problem of almost all Delphi + Access colleagues - dynamically created, compressed access database (* .mdb)

zhaozj2021-02-08  311

Dynamically created, compressed access database (* .mdb)

Disclaimer: This is a solution for no ancient people. After a little blow, I am too excited!) Yesterday morning, the current hard work, finally released all, now give you to everyone:

First, create the experience through the OLE way to access the Word, Excel file through the OLE way, I don't say too much, write the specific code directly, add: Uses comoBJ; Implementation section: Procedure TFormoffice. BitBtn1Click (Sender: TObject); var CreateAccess: OleVariant; begin CreateAccess: = CreateOleObject ( 'ADOX.Catalog'); CreateAccess.Create ( 'Provider = Microsoft.Jet.OLEDB.4.0; Data Source = c: /Aceco.mdb' END;

Description: 1. Create Aceco.mdb in C: / Next, it is an Access2000 format, can't be opened with Access 97; 3. The system needs to install MDAC, this is good news, customers do not need to install Access can also

Second, the creation of DBENGINE is the key to the key. It is the reason I must write! Do you still remember when you install Delphi, if you choose a custom installation (I usually write controls with Delphi, it is of course, the smaller the better), there will be a lot of installation options, let you choose Access 97 or Access2000, and MDAC, etc. That's the problem! Delphi5.0 encapsulates ready-made classes, but everyone doesn't pay attention, it is located in: $ delphi5 / imports directory! There is a DAO97.DCU file, which is done through DAO350.DLL, where the definition part is, and the DAO350.dll is as follows! OK, now, everything understands (unfortunately I spent a day!). Then the specific implementation is too convenient, the specific process is as follows: Uses DAO97; Uses DAO97; Implementation section: Procedure TFormOffice.bitbtn4click (sender: TOBJECT); var engine: dbEngine; begin Engine: = CODBENGINE.CREATE; engine.createDatabase ('c: /newaccess.mdb', '; langid = 0x0804; cp = 936; country = 0;', dbencrypt);

Description: 1. Create newaccess.mdb in c: / down; 2, language country is Simplified Chinese; ', 0,' '); ); Then rename the C: /God.mdb (Renamefile ('c: /god.mdb', 'c: /invoice.mdb');) Third, create through Access 97, then copy four, create through the ODBC API function

Supplement: 1. If you are created through the OLE mode, if it is access97, it may be createaccess.create ('provider = microsoft.jet.Oledb.3.5.1; data source = c: /Aceco.mdb');, 嘿嘿, your younger brother VB is really unless, but also look at it again (which can require a low version of MDAC).

2, is provided on CreateDatabase countries: Module LanguageConstants; // DAO predefined constants dbLangArabic =; LANGID = 0x0401; CP = 1256; COUNTRY = 0; dbLangCzech =; LANGID = 0x0405; CP = 1250; COUNTRY = 0; dbLangDutch =. ; LANGID = 0x0413; CP = 1252; COUNTRY = 0; dbLangGeneral =; LANGID = 0x0409; CP = 1252; COUNTRY = 0; dbLangGreek =; LANGID = 0x0408; CP = 1253; COUNTRY = 0; dbLangHebrew =; LANGID = 0x040D; CP = 1255; COUNTRY = 0; dbLangHungarian =; LANGID = 0x040E; CP = 1250; COUNTRY = 0; dbLangIcelandic =; LANGID = 0x040F; CP = 1252; COUNTRY = 0; dbLangNordic =; LANGID = 0x041D; CP = 1252; COUNTRY = 0; dbLangNorwDan =; LANGID = 0x0414; CP = 1252; COUNTRY = 0; dbLangPolish =; LANGID = 0x0415; CP = 1250; COUNTRY = 0; dbLangCyrillic =; LANGID = 0x0419; CP = 1251; COUNTRY = 0; dbLangSpanish = ; LANGID = 0x040A; CP = 1252; COUNTRY = 0; dbLangSwedFin =; LANGID = 0x040B; CP = 1252; COUNTRY = 0; dbLangTurkish =; LANGID = 0x041F; CP = 1254; COUNTRY = 0; dbLangJapanese =; LANGID = 0x0411; CP = 932; country = 0; dbLangChineseSimplified =; LANGID = 0x0804; CP = 936; COUNTRY = 0; dbLangChineseTraditional =; LANGID = 0x0404; CP = 950; COUNTRY = 0; dbLangKorean =; LANGID = 0x0412; CP = 949; COUNTRY = 0; dbLangThai =; LANGID = 0x041e; cp = 874; country = 0; dblangslovenian =; langId = 0x0424; CP = 1250; country = 0;

3. About database version information in CreateDatabase ENUM DATABASETYPEENUM; DBVERSION10 = 1; dbndecrypt = 2; dbDecrypt = 4; dbversion11 = 8; dbversion20 = 16; dbversion30 = 32; 4, other aspects, I hope you will add supplements.

Starfarm -> Hank (starfarm@263.net) 2000/12/29

转载请注明原文地址:https://www.9cbs.com/read-933.html

New Post(0)