如何用C#编程实现将有分隔符的CSV数据文件导入到access数据库文件中去

2024-12-20 03:26:49
推荐回答(1个)
回答1:

objStreamReader = new StreamReader(strPath, System.Text.Encoding.Unicode);
while (objStreamReader.Peek() >= 0)
{
string strLine = objStreamReader.ReadLine();
string[] splitData = strLine.Split(',');
Service clsService = new Service();
//clsService.ID = splitData[0];
clsService.Date = splitData[1];
clsService.Subject = splitData[2];
clsService.CustomerNM = splitData[3];
clsService.Birthday = splitData[4];
clsService.Commodity = splitData[5];
clsService.Address = splitData[6];
clsService.Identity = splitData[7];
clsService.Money = splitData[8];
clsService.Maturity = splitData[9];
clsService.Remarks = splitData[10];

//导入数据
clsProService.InsertProcess(clsService);