Access has a strong import and export function. you can use select... the into syntax is used to import non-access tables. this import method is highly efficient. Nearly 0.3 million pieces of data will be imported in less than half a minute.
Assume that a DBASE table "customer. DB" is located in the D:/DBASE directory and needs to be imported into access. First, create an ADO connection pointing to the Access database to be imported, and then execute the SQL statement:
Select * into customer from customer in "D:/DBASE" "dbase iv ;"
Or the access table already exists and is imported using insert into... select.
Insert into customer select customer in "D:/DBASE" "dbase iv ;"
The basic form of the two statements:
Select field1 [, field2 [,...] into destination table [in external database]
From source table [in external database]
Insert into destination table [(field1 [, field2 [,...])] [in external database]
Select field1 [, field2 [,...]
From source table [in external database]
External Database = path | ["path" "type"] | ["" [type; database = path]
If the external database is an Access database, you do not need to specify the type. if it is other, You need to specify, such as "Paradox 3.x"," Paradox 4.x" "Paradox 5.x"," Paradox 7.x", "dbase iii", "dbase iv", "text"
1. Import from Paradox
Select * into customer from customer in "D:/Data" "Paradox 7.x ;"
2. import from a text file. Note that if the first row of tfxx.txt is not a column name, you must use schema. ini to specify the column name and data type.
Select * into tfxx fr0m limit tfxx.txt] in "D:/Data" "text ;"
3. The table already exists. append the import.
Insert into info select * From nation tfxx.txt] in "E:/Data" "text ;"
3. Export to a text file
Select * into convert tfxx2.txt] in "E:/Data" "text;" from tfxx
It generates schema. ini automatically.
4. Use a chain table.
Access Database supports chain tables, which can be linked to external database tables. If you do not want to import data, you can create a chain table to use external data.
VaR
Dbengine, DB, tdflinked: olevariant;
Begin
Oldtick: = gettickcount;
Dbengine: = createoleobject ('dao. dbengine.36 ');
DB: = dbengine. opendatabase ('info. mdb ', emptyparam );
Tdflinked: = dB. createtabledef ('tfxx _ link'); // tfxx_link indicates the table name.
Tdflinked. Connect: = 'text; database = D:/data ';
Tdflinked. sourcetablename: = 'tfxx.txt ';
DB. tabledefs. append (tdflinked );
End;
The preceding SQL and code have been successfully tested in XP SP2 and Delphi 7.