首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi7 怎么将txt读到DBGRID显示,同时要写入数据库

2013-01-11 
delphi7 如何将txt读到DBGRID显示,同时要写入数据库我有一个Txt文件,格式如:68859102032000000314,马贵元,

delphi7 如何将txt读到DBGRID显示,同时要写入数据库
我有一个Txt文件,格式如:
68859102032000000314,马贵元,2000/09/20,10.33,632121196308124514,,
68859102032000000569,马孝福,2001/03/02,208.71,632801196403080516, ,
68859102032000000619,马麻乃,2001/03/23,270.19,622923195101155313,13892259441,
里面有很多行这样的数据,我想把把导入到mdb中的表db,DB表字段有
帐号,姓名,日期,卡号,手机号
写入到表中后窗口上的DBGRID要能显示帐号,姓名,日期,卡号,手机号
日期这一列写到表的日期字段中格式为20000920这样的,把/去掉


高人急救啊,如何写代码,导入按钮的代码如何弄?读入TXT文件时以逗号分隔符
[解决办法]
按你的方式读取字符串后再用stringreplace('2012/09/09','/','',[rfReplaceAll])即可
[解决办法]
二楼的代码也不是楼主本人写的吧,竟然不会再读下一个。

       zh:=copy(temp, 1, pos(',',temp)-1);
       temp:=copy(temp,pos(',',temp)+1,length(temp)-pos(',',temp));
       ckr:=copy(temp, 1, pos(',',temp)-1);
       temp:=copy(temp,pos(',',temp)+1,length(temp)-pos(',',temp));
       kh:=copy(temp, 1, pos(',',temp)-1);
       temp:=copy(temp,pos(',',temp)+1,length(temp)-pos(',',temp));
       temp:=copy(temp,pos(',',temp)+1,length(temp)-pos(',',temp));//直接取10.33后面的字符串
       sfz:=copy(temp, 1, pos(',',temp)+1);
       temp:=copy(temp,pos(',',temp)+1,length(temp)-pos(',',temp));
       kh:=stringreplace(kh,'/','',[rfReplaceAll]);//这个函数应该是strutils里的,需要引用。

 

热点排行