请问怎么将Excel文件转换为dbase3格式!!急!! 请问怎么将Excel文件转换为dbase3格式!!急!!请给个例子!!谢谢[email protected] 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下 面 的 例 子 展 示 了 从Foxpro 到SQL Server 的 数 据 转 移 方 法。 至 于 其 他 系 统 间 的 数 据 转 移, 只 要 根 据 目 标 系 统 的 数 据 定 义 要 求, 修 改 相 应 的Insert 语 句。 程 序 代 码 如 下: unit ConvertDBF;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DBTables, Db, Grids, DBGrids;type TfrmConvertDB = class(TForm) btnOK: TButton; Label1: TLabel; db1: TDatabase; {用于连接老数据库系统} db2: TDatabase; {用于连接新数据库系统} dbg: TDBGrid; tblSource: TTable; {dbg的Datasource}qryInsert: TQuery; {用于存放生成的SQL Insert语句} srcSource: TDataSource; tblDest: TTable; {DBGrid1的Datasource} DBGrid1: TDBGrid; srcDest: TDataSource; edFromtbl: TEdit; Label2: TLabel; Label3: TLabel; edToTbl: TEdit; procedure btnOKClick(Sender: TObject); private { Private declarations } public { Public declarations } end;var frmConvertDB: TfrmConvertDB;implementation{$R *.DFM}procedure TfrmConvertDB.btnOKClick (Sender: TObject);var iField :integer;begin if ((edTotbl.text<>’’) and (edFromtbl.text<>’’))then begin tblSource.TableName:=edFromtbl.text; {指定TableName} tblDest.TableName:=edTotbl.text; with tblSource do begin Open; {打开老系统的表} while EOF=FALSE do begin {逐条记录处理} qryInsert.SQL.Clear;qryInsert.sql.Add(’Insert into ’+edTotbl.text + ’(’); for iField:=0 to dbg.FieldCount-1 do begin qryInsert.sql.add (dbg.Fields[iField].DisplayLabel); if iField<>dbg.FieldCount-1 then qryInsert.sql.add(’,’); end; qryInsert.sql.add(’) values(’);for iField:=0 to dbg.FieldCount-1 do begin {进行数据类型转换} if dbg.fields[iField].DataType=ftInteger then qryInsert.sql.add(inttostr (dbg.fields[iField].asInteger)); if dbg.fields[iField].DataType=ftFloat then qryInsert.sql.add(floattostr (dbg.fields[iField].asFloat)); if dbg.fields[iField].DataType=ftDate then qryInsert.sql.add(’’’’+datetostr (dbg.fields[iField].asDateTime)+’’’’); if dbg.fields[iField].DataType=ftString then begin if dbg.fields[iField].asString<>’’ then qryInsert.sql.add(’’’’+dbg.fields [iField].asString+’’’’) else qryInsert.sql.add(’NULL’); end; if iField<>dbg.FieldCount-1 then qryInsert.sql.add(’,’); end; qryInsert.sql.add(’)’);qryInsert.ExecSQL; {把数据插入到新系统的表中} next; end; end; tblDest.Close; tblDest.Open;; ShowMessage(’ 转换完毕! ’); end else ShowMessage (’请输入要插入数据的表的名称 ’);end;end. 数据库主从表的疑问 怎样遍历ScrollBox1控件里的控件,并释放删除? 关于存储过程,执行,事务提交问题??(求助) IntraWeb7 的问题 传奇密码这样的记录工具怎么个思路! 关于f1book的一个问题 各位,大哥,socketconnection做三层系统问题 怎么做一个象OICQ那样的窗体? ADOConnect && SQL-Server 从那里可以下载到formula one控件,我怎么也找不到,救命呀!!! 在项目开发中,各个模块用DLL调用,为什么全局变量调用不到? 100分求crystal report 8.5的安装密码/CD_KEY
Windows, Messages, SysUtils, Classes,
Graphics, Controls, Forms, Dialogs,
StdCtrls, DBTables, Db, Grids, DBGrids;type
TfrmConvertDB = class(TForm)
btnOK: TButton;
Label1: TLabel;
db1: TDatabase; {用于连接老数据库系统}
db2: TDatabase; {用于连接新数据库系统}
dbg: TDBGrid;
tblSource: TTable; {dbg的Datasource}
qryInsert: TQuery;
{用于存放生成的SQL Insert语句}
srcSource: TDataSource;
tblDest: TTable; {DBGrid1的Datasource}
DBGrid1: TDBGrid;
srcDest: TDataSource;
edFromtbl: TEdit;
Label2: TLabel;
Label3: TLabel;
edToTbl: TEdit;
procedure btnOKClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
frmConvertDB: TfrmConvertDB;implementation{$R *.DFM}
procedure TfrmConvertDB.btnOKClick
(Sender: TObject);
var iField :integer;
begin
if ((edTotbl.text<>’’) and
(edFromtbl.text<>’’))then begin
tblSource.TableName:=edFromtbl.text;
{指定TableName}
tblDest.TableName:=edTotbl.text;
with tblSource do begin
Open; {打开老系统的表}
while EOF=FALSE do begin
{逐条记录处理}
qryInsert.SQL.Clear;
qryInsert.sql.Add
(’Insert into ’+edTotbl.text + ’(’);
for iField:=0 to dbg.FieldCount-1 do begin
qryInsert.sql.add
(dbg.Fields[iField].DisplayLabel);
if iField<>dbg.FieldCount-1 then
qryInsert.sql.add(’,’);
end;
qryInsert.sql.add(’) values(’);
for iField:=0 to dbg.FieldCount-1 do begin
{进行数据类型转换}
if dbg.fields[iField].DataType=ftInteger then
qryInsert.sql.add(inttostr
(dbg.fields[iField].asInteger));
if dbg.fields[iField].DataType=ftFloat then
qryInsert.sql.add(floattostr
(dbg.fields[iField].asFloat));
if dbg.fields[iField].DataType=ftDate then
qryInsert.sql.add(’’’’+datetostr
(dbg.fields[iField].asDateTime)+’’’’);
if dbg.fields[iField].DataType=ftString then begin
if dbg.fields[iField].asString<>’’ then
qryInsert.sql.add(’’’’+dbg.fields
[iField].asString+’’’’)
else
qryInsert.sql.add(’NULL’);
end;
if iField<>dbg.FieldCount-1
then qryInsert.sql.add(’,’);
end;
qryInsert.sql.add(’)’);
qryInsert.ExecSQL;
{把数据插入到新系统的表中}
next;
end;
end;
tblDest.Close;
tblDest.Open;;
ShowMessage(’ 转换完毕! ’);
end
else
ShowMessage
(’请输入要插入数据的表的名称 ’);
end;
end.