关于Visual Foxpro 6.0 数据库中的表中的数据转移到

Rose1234567890 2003-10-21 07:48:06
关于Visual Foxpro 6.0 数据库中的表中的数据转移到
ACCESS 2000 数据库的表中的问题。
Visual Foxpro 6.0 表的结构为:
aa 字符型
bb 字符型
cc 字符型
ACCESS 2000 表的结构为
aa 文本型
bb 文本型
cc 文本型
procedure TForm1.Button1Click(Sender: TObject);
var
iField :integer;
begin
tblSource.DatabaseName:='sun1';
tblSource.TableName:='sun1';
tblSource.Active:=true;
tblDest.DatabaseName:='sun';
tblDest.TableName:='a';
tblDest.Active:=true;
with tblSource do begin
Open; {打开老系统的表}
while EOF=FALSE do begin
{逐条记录处理}
qryInsert.DatabaseName:='sun';
qryInsert.SQL.Clear;
qryInsert.sql.Add('Insert into "a"' + '(');
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;



执行后提示
tblDest:Type mismatch for field 'aa',expecting:integer actual:String
是不是这里出问题了,该怎么改呀!
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+'''')





...全文
37 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

2,495

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧