ds.Tables[0].Rows.Count你这句的意思是表0的记录数,当你执行test1,test2时没有结果,为0,test3时,记录存在故为1,test4时,没有记录数,但是ds.Tables[0].Rows仍然存在你刚才的结果,而没有清空。所以为1。

解决方案 »

  1.   

    输出表中列“TRANS_NO”所的有值:foreach(DataRow Myrows in ds.Tables[0].Rows())
    {
        Console.WriteLine(Myrows["TRANS_NO"].ToString());
    }
      

  2.   

    if you only have those files and the file names always start with "test", why cannot you just do "select * from TESTTABLE where TRANS_NO like 'test%'"and do one Fill on the DataSet? then you could either check each of the records or use DataView to fill out:da.Fill(ds,"BIZCMASTER");
    DataView dv = new DataView(da.Tables["BIZCMASTER"]);
    foreach (FileInfo fri in fileArr)
    {
        dv.RowFilter = "TRANS_NO = '" + fri.Name + "'";
        Console.WriteLine("{0}:{1}", fri.Name, dv.Count);
    }
      

  3.   

    我怎样才可以清空ds.Tables[0].Rows.Count呢?我试着将它置0,结果系统告诉我,它是只读的。还有,我的文件名不可能只是test1,test2...的形式。
      

  4.   

    每一次用ds.clear()清空其记录.