Link to home
Start Free TrialLog in
Avatar of jtylerhill
jtylerhill

asked on

Check for the existence of a table within a dataset

Hi,
I'm building a dataset dynamically and the dataset contains several tables (which are named dynamically).  Obviously when I try to access the data at a later point, if I reference a table that doesn't exist I will get an error.  How can I first check to see if a table exists within the dataset?  (e.g. if exists dataset.tables("table1"))

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of anv
anv

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jtylerhill
jtylerhill

ASKER

Thanks!
In case anybody needs this in the future, below is how I implemented  anv's solution:


Dim x, i As Integer
Dim dt As DataTable
x = MyDataSet.Tables.Count - 1
For i = 0 To x
   dt = dsKeys.Tables(i)
   If StrComp(dt.TableName(), "MyTableName", CompareMethod.Text) = 0 Then
      MsgBox("Table Found")
   End If
Next

Thanks again anv!