I have a Dataset and having 'n' number of tables .how can i delete the table from dataset if tables have Parent and Child relationship .
Code:
if (m_dsSet.Tables[TableName] != null)
{
for (int iCount = m_dsSet.Tables[TableName].ChildRelations.Count - 1; iCount >= 0; iCount--)
{
m_dsSet.Tables[TableName].ChildRelations[iCount].ChildTable.Constraints.Remove(m_dsSet.Tables[TableName].ChildRelations[iCount].RelationName);
m_dsSet.Tables[m_sLevelName].ChildRelations.RemoveAt(iCount);
}
m_dsSet.Tables[TableName].ChildRelations.Clear();
m_dsSet.Tables[TableName].ParentRelations.Clear();
m_dsSet.Tables[TableName].Constraints.Clear();
}
I am able to Delete only the rows ..but stil Table is left in dataset..
You need to call TableCollection.Remove
m_dsSet.Tables.Remove(TableName);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With