I have created an application which reads the records from excel files and 2D arrays and after merging them it will pass the data to ds.table[x]. i would like to know if there is a way for me to check if the ds.table[x] exist? and how can i do that in code behind ?
            Asked
            
        
        
            Active
            
        
            Viewed 1.5k times
        
    5
            
            
        
        John Saunders
        
- 160,644
 - 26
 - 247
 - 397
 
        CodeMonkey
        
- 2,511
 - 4
 - 27
 - 38
 
1 Answers
8
            You can check with the following if statement,
 if(ds.Tables.Contains("TableName"))
- 
                    I've tried that before and it doesn't work. i think its because that statement checks whether if a table contains "thestring" while im looking for something like if ds contains table[x] – CodeMonkey Jun 15 '15 at 03:31
 - 
                    1It _does_ work. See [`DataTableCollection.Contains` method](https://msdn.microsoft.com/en-us/library/ye3t49b6.aspx). – John Saunders Jun 15 '15 at 03:56
 - 
                    1If you do not know the name of table, then you can just check the `ds.Tables.Count` is > than (int)x – Eric Jun 15 '15 at 04:18
 - 
                    Check http://stackoverflow.com/questions/16146473/check-if-table-exists-with-if-statement-in-c for a few other solutions. – coder231 Jun 15 '15 at 15:25