闁衡偓閹増顥� (0) +1 閻犙嶆嫹 (0) +1 闂婎亷鎷� (0) +1
闁衡偓閹増顥戦柟瀛樺姇婵拷闁哄被鍎冲﹢鍛村绩閹増顥�>>
0

正在阅读:用AdoDataSet实现数据表的导入导出用AdoDataSet实现数据表的导入导出

2004-08-10 10:08 出处:CSDN 作者:zhxfzhxf1 责任编辑:linjixiong

  2.数据表的导入

  下面是一个导入操作的示例(假定存在相同主键记录时更新目的表;假定数据表为单主键字段,且其字段类型为字符串型)。


  Procedure  ImportData(strFileName, strTableName, strKeyFieldName: string);

  begin

  with AdoDataSet1 do

  begin

  Close;

  LoadFromFile(strFileName);

  First;

  While not eof do

  begin

  StrKeyValue := FieldByName(strKeyFieldName).AsString;

  If RecordInDest(strTableName, strKeyFieldName, strKeyValue) then

  begin

  AdoDataDest.Close;

  AdoDataSetDest.CommandText := Format(‘select * from %s where %s=%s’,[strTableName, strKeyFieldName, QuotedStr(strKeyValue)]);

  AdoDataSetDest.Open;

  AdoDataSetDest.First;

  AdoDataSetDest.Edit;

  for I:=0 to FieldList.Count-1 do

  AdoDataSetDest.Fields[I] := Fields[I];

  AdoDataSetDest.Post;

  end

 


察看评论详细内容 我要发表评论
作者笔名 简短内容 发表时间
:

键盘也能翻页,试试“← →”键

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品
閹靛婧€鐠佸潡妫�閸ョ偛鍩屾い鍫曞劥