Any difference between dataset Reset and Clear?

  • Thread starter Thread starter Earl
  • Start date Start date
E

Earl

I've used both Reset and Clear, but I'm not sure how they differ. In
particular, the Help says that Reset, "Resets the DataSet to its original
state." Ummmmm, ok. Does this mean before the dataset existed? Before you
added a table or tables? What would be the "original state"? Maybe in other
words, Clear(ed) "by removing all rows in all tables"?
 
This is what happens inside of Reset(), so as you can see Reset actually
calls Clear() as part of it's internal processing. Basically Clear() is
removing the data from the dataset while leaving the tables and relations
intact while Reset() is removing the relations, the data and the tables from
the DataSet.

public virtual void Reset()
{
int num1;
ConstraintCollection collection1;
int num2;
for (num1 = 0; (num1 < this.Tables.Count); ++num1)
{
collection1 = this.Tables[num1].Constraints;
for (num2 = 0; (num2 < collection1.Count); ++num2)
{
if ((collection1[num2] is ForeignKeyConstraint))
{
collection1.Remove(collection1[num2]);
continue;
}
}
}
this.Relations.Clear();
this.Clear();
this.Tables.Clear();
}

and this is what happens inside of Clear()

public void Clear()
{
int num1;
this.OnClearFunctionCalled(null);
bool flag1 = this.EnforceConstraints;
this.EnforceConstraints = false;
for (num1 = 0; (num1 < this.Tables.Count); ++num1)
{
this.Tables[num1].Clear();
}
this.EnforceConstraints = flag1;
}
 
Thanks Steve, that's what I was looking for.

Steve Willcock said:
This is what happens inside of Reset(), so as you can see Reset actually
calls Clear() as part of it's internal processing. Basically Clear() is
removing the data from the dataset while leaving the tables and relations
intact while Reset() is removing the relations, the data and the tables from
the DataSet.

public virtual void Reset()
{
int num1;
ConstraintCollection collection1;
int num2;
for (num1 = 0; (num1 < this.Tables.Count); ++num1)
{
collection1 = this.Tables[num1].Constraints;
for (num2 = 0; (num2 < collection1.Count); ++num2)
{
if ((collection1[num2] is ForeignKeyConstraint))
{
collection1.Remove(collection1[num2]);
continue;
}
}
}
this.Relations.Clear();
this.Clear();
this.Tables.Clear();
}

and this is what happens inside of Clear()

public void Clear()
{
int num1;
this.OnClearFunctionCalled(null);
bool flag1 = this.EnforceConstraints;
this.EnforceConstraints = false;
for (num1 = 0; (num1 < this.Tables.Count); ++num1)
{
this.Tables[num1].Clear();
}
this.EnforceConstraints = flag1;
}

--
Steve Willcock (MCSD for Microsoft.NET)
http://www.willcockconsulting.com/

Earl said:
Thanks. But those topics just repeated what I posted.
http://msdn.microsoft.com/library/d...tml/frlrfsystemdatadatasetclassresettopic.asp
Before
you
 
Back
Top