Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Remove Table from Dataset when it has relations?

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..

like image 529
Aravind Srinivas Avatar asked Oct 04 '22 12:10

Aravind Srinivas


1 Answers

You need to call TableCollection.Remove

 m_dsSet.Tables.Remove(TableName); 
like image 55
Kim Avatar answered Oct 13 '22 10:10

Kim