日期:2014-05-16  浏览次数:20865 次

请帮忙,关于文本读取?
我不想读取文本的最后一行(### 82175 records)值,怎么能实现?


c#代码如下:
我先是从文本一行行的读取出,写入到DATATABLE里,前面都没有问题的,都可以写入到DATATABLE里,就是最后一列报错,所以我想把最后一列不读取,不写入到DATATABLE里,怎么能实现?
谢谢了!

using (SqlConnection connection = new SqlConnection(connstr))
                {
                    connection.Open();


                    SqlDataAdapter SqlData = new SqlDataAdapter("select * from t_dsl where storecode='99999'", connection);
                    SqlData.Fill(dt);

                    StreamReader sr = new StreamReader("d:/stdata/ddsl.txt", Encoding.Default);
                    string line, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13;
                    int mm=0;
                  while ((line = sr.ReadLine()) != null)
                   {
                   
                            a1 = line.Substring(0, 8);
                            a2 = line.Substring(8, 3);
                            a3 = line.Substring(11, 10);
                            a4 = line.Substring(21, 2);
                            a5 = line.Substring(23, 1);
                            a6 = line.Substring(24, 1);
                            a7 = line.Substring(25, 5);
                            a8 = line.Substring(30, 12);
                            a9 = line.Substring(42, 15);
         &