有人识货吗?From《Master Delphi6》EBook P710-P712(100分)

  • 主题发起人 主题发起人 doxpix
  • 开始时间 开始时间
D

doxpix

Unregistered / Unconfirmed
GUEST, unregistred user!
Importing and Exporting
The Jet engine is particularly adept at importing and exporting data. The process of exporting
data is the same for each export format and consists of executing a SELECT statement
with a special syntax. Let’s start with an example of exporting data from the Northwind
Access database to a Paradox table. You will need an active TADOConnection, called ADOConnection1
in our example, that uses the Jet 4.0 OLE DB Provider to open the Northwind.
mdb Access database. The following code exports the Customers table to a Paradox
Customers.db file:
ADOConnection1.Execute(‘SELECT * INTO Customers ‘ +
‘IN “C:/Temp” “Paradox 7.x;” FROM CUSTOMERS’);
Let’s look at the pieces of this SELECT statement. The INTO clause specifies the new
table that will be created by the SELECT statement;
this table must not already exist. The
IN clause specifies the database to which the new table is added;
in Paradox, this is a directory
that already exists. The clause immediately following the database is the name of the
IISAM driver to be used to perform the export. You must include the trailing semicolon at the
end of the driver name. The FROM clause is a regular part of any SELECT statement.
All export statements follow these same basic clauses, but you will find that some IISAM
drivers have differing interpretations of what a database is. I’ll do
another couple of examples
to demonstrate the differences. Here, we export the same data to Excel:
ADOConnection1.Execute(‘SELECT * INTO Customers ‘ +
‘IN “Northwind.xls” “Excel 8.0;” FROM CUSTOMERS’);
A new Excel file called Northwind.xls is created in the application’s current directory. A
workbook called Customers is added, containing all of the data of the Customers table in
Northwind.mdb. You can also export data to Excel by automating Excel, but if you have ever
done this you will know that this ADO solution is simpler by far.
This next example exports the same data to HTML:
ADOConnection1.Execute(‘SELECT * INTO [Customers.htm] ‘ +
‘IN “C:/Temp” “HTML Export;” FROM CUSTOMERS’);
In this example, the database is the directory, as it was for Paradox but not for Excel. The
table name must include the .htm extension and, therefore, it must be enclosed in square
brackets. Notice that the name of the IISAM driver is “HTML Export”, not just "HTML",
because this driver can only be used for exporting to HTML.
The last IISAM driver we’ll look at in this investigation of the Jet engine is the sister to
HTML Export: HTML Import. Add a TADOTable to a form, set its ConnectionString to
use the Jet 4.0 OLE DB Provider and Extended Properties to HTML Import. Set the database
name to the name of the HTML file created by the export a few moments ago—that is,
C:/Temp/Customers.htm. Close the connection string editors and set the TableName to
Customers. Open the table and you have just imported the HTML file! Bear in mind,
though, that the name of this IISAM driver is “HTML Import”, not just "HTML". If you
attempt to update the data in any way, you’ll receive an error because this driver is intended
for import only. Finally, if you create your own HTML files containing tables and want to
open these tables using this driver, then
remember that the name of the table is the value of
the CAPTION tag of the HTML TABLE.
 
没听说过,看上去不错啊!
 
用处不是太大
毕竟用ACCESS做数据库开发的系统太少了 [:)]
 
是不错,我之前有试过导出到excel,速度非常快。
 
to xianjun:
不一定非得用Access啊!
Paradox,dBase,SQL Server都可以啊,前提就是要装ADO引擎.
 
Jet engine 不是只支持Access吗? 你试过?
 
哦,xianjun是对的.
只支持对Access的导入导出.
 

Similar threads

A
回复
0
查看
992
Andreas Hausladen
A
A
回复
0
查看
943
Andreas Hausladen
A
A
回复
0
查看
619
Andreas Hausladen
A
A
回复
0
查看
819
Andreas Hausladen
A
A
回复
0
查看
478
Andreas Hausladen
A
后退
顶部