delphi中的adodataset是支持ado访问的主要组件,它支持从数据表直接获取数据,支持用sql语句获取数据。最重要的是,它定义和实现了两个重要的例程:
procedure loadfromfile(const filename: widestring);它从文件中加载数据集。 |
procedure savetofile(const filename: string = ''; format: tpersistformat = pfadtg);它将数据集保存到文件中。format确定文件中数据集的保存格式,可以使用的有pfadtg (advanced data tablegram format)、pfxml(extendable markup language)。
因此adodataset是实现导入导出的良好的基础。
1.数据表的导出
导出数据表的操作如下:
1)打开数据表,设置需要导出的条件;
2)使用adodataset,调用savetofile导出记录;
下面是一个导出操作的示例(假定导出指定数据表的全部记录)。
procedure exportdata(strfilename, strtablename: string); begin with adodataset1 do begin close; commandtext := ‘select * from ’ + strtablename; open; savetofile(strfilename); close; end; end; |
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器