DataSet.Tables.Count属性在处理后保留其值 [英] DataSet.Tables.Count Property preserve its value after dispose

查看:92
本文介绍了DataSet.Tables.Count属性在处理后保留其值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用DataSet从数据库接收数据,
填充的过程,根据情况将数据表放入一张表或三张表,

问题在于,当DataSet充满三个表时,它仍然保留其Count中的表数,例如:

 SpecificDataSet.Tables.Count 


就像情况是一个表一样,它的属性SpecificDataSet.Tables.Count中仍然有3个,这在我的项目中导致错误

我使用了清除方法,但对我没有帮助.

 SpecificDataSet.Clear(); 


 SpecificDataSet.Tables.Clear(); 



任何人都有想法

谢谢.....................编程.

因此 DataSet.Clear [确实可以 [ DataSet ds = DataSet();


Hi every body,

I am using DataSet to receive data from database,
the procedure which fill it, put in dataset one table or three table according to the case,

the problem is that when DataSet filled with three tables it still preserve with that number of tables in its Count like:

SpecificDataSet.Tables.Count


as when the case is one table only it still has 3 in its property SpecificDataSet.Tables.Count, and that cause error in my project

I used Clear method but not help me.

SpecificDataSet.Clear();


SpecificDataSet.Tables.Clear();



Any body have any idea

Thanks...

When a method does not do what you except look at the documentation, the documentation is your friend not your enemy if you want to be serious about programming.

So the documentation for
DataSet.Clear[^] clearly states that all rows in all the contained tables are removed. It mentions nothing about removing the contained DataTable''s so it does not do that.

You retrieve the number of tables like this SpecificDataSet.Tables.Count that immediately tells me that SpecificDataSet.Tables is some form of collection and thus it most likely have a Clear method,and what do you know it does[^]. So you should write SpecificDataSet.Tables.Clear()


Use

DataSet ds = new DataSet();


这篇关于DataSet.Tables.Count属性在处理后保留其值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆