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

C#怎么实现openfiledialog选中并读取文本内容按照格式写入相应的数据库字段中

2012-02-01 
C#如何实现openfiledialog选中并读取文本内容按照格式写入相应的数据库字段中比如文本格式如下:1234567890

C#如何实现openfiledialog选中并读取文本内容按照格式写入相应的数据库字段中
比如文本格式如下:

1234567890,123,123,one
2142134245,888,888,two
...

相应的SQL数据库字段

num,d1,d2,order

代码上如何实现?

[解决办法]
using System.IO;


StreamReader reader = new StreamReader(fileName, Encoding.Default);
string line = null;
while(...)
{
reader.ReadLine();
string[] params = line.Split( ', ');
if(params.Length == 4)
AddToDataBase(params);
}


[解决办法]
笨办法 :
StreamReader reader = new StreamReader(fileName, Encoding.Default);
string line = null;
while(...)
{
reader.ReadLine();
string[] params = line.Split( ', ');
if(params.Length == 4)
AddToDataBase(params);
}

热点排行